123456789_123456789_123456789_123456789_123456789_

Class: Racc::Grammar::PrecedenceDefinitionEnv

Relationships & Source Files
Inherits: Object
Defined in: lib/racc/grammar.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(g) ⇒ PrecedenceDefinitionEnv

[ GitHub ]

  
# File 'lib/racc/grammar.rb', line 366

def initialize(g)
  @grammar = g
  @prechigh_seen = false
  @preclow_seen = false
  @reverse = false
end

Instance Attribute Details

#reverse (readonly)

[ GitHub ]

  
# File 'lib/racc/grammar.rb', line 373

attr_reader :reverse

Instance Method Details

#higher

[ GitHub ]

  
# File 'lib/racc/grammar.rb', line 375

def higher
  if @prechigh_seen
    raise CompileError, "prechigh used twice"
  end
  @prechigh_seen = true
end

#left(*syms)

[ GitHub ]

  
# File 'lib/racc/grammar.rb', line 392

def left(*syms)
  @grammar.declare_precedence :Left, syms.map {|s| @grammar.intern(s) }
end

#lower

[ GitHub ]

  
# File 'lib/racc/grammar.rb', line 382

def lower
  if @preclow_seen
    raise CompileError, "preclow used twice"
  end
  if @prechigh_seen
    @reverse = true
  end
  @preclow_seen = true
end

#nonassoc(*syms)

[ GitHub ]

  
# File 'lib/racc/grammar.rb', line 400

def nonassoc(*syms)
  @grammar.declare_precedence :Nonassoc, syms.map {|s| @grammar.intern(s)}
end

#right(*syms)

[ GitHub ]

  
# File 'lib/racc/grammar.rb', line 396

def right(*syms)
  @grammar.declare_precedence :Right, syms.map {|s| @grammar.intern(s) }
end