Class: Racc::Grammar::PrecedenceDefinitionEnv
- Defined in:
- lib/racc/grammar.rb
Instance Attribute Summary collapse
-
#reverse ⇒ Object
readonly
Returns the value of attribute reverse.
Instance Method Summary collapse
- #higher ⇒ Object
-
#initialize(g) ⇒ PrecedenceDefinitionEnv
constructor
A new instance of PrecedenceDefinitionEnv.
- #left(*syms) ⇒ Object
- #lower ⇒ Object
- #nonassoc(*syms) ⇒ Object
- #right(*syms) ⇒ Object
Constructor Details
#initialize(g) ⇒ PrecedenceDefinitionEnv
Returns a new instance of PrecedenceDefinitionEnv.
368 369 370 371 372 373 |
# File 'lib/racc/grammar.rb', line 368 def initialize(g) @grammar = g @prechigh_seen = false @preclow_seen = false @reverse = false end |
Instance Attribute Details
#reverse ⇒ Object (readonly)
Returns the value of attribute reverse.
375 376 377 |
# File 'lib/racc/grammar.rb', line 375 def reverse @reverse end |
Instance Method Details
#higher ⇒ Object
377 378 379 380 381 382 |
# File 'lib/racc/grammar.rb', line 377 def higher if @prechigh_seen raise CompileError, "prechigh used twice" end @prechigh_seen = true end |
#left(*syms) ⇒ Object
394 395 396 |
# File 'lib/racc/grammar.rb', line 394 def left(*syms) @grammar.declare_precedence :Left, syms.map {|s| @grammar.intern(s) } end |
#lower ⇒ Object
384 385 386 387 388 389 390 391 392 |
# File 'lib/racc/grammar.rb', line 384 def lower if @preclow_seen raise CompileError, "preclow used twice" end if @prechigh_seen @reverse = true end @preclow_seen = true end |
#nonassoc(*syms) ⇒ Object
402 403 404 |
# File 'lib/racc/grammar.rb', line 402 def nonassoc(*syms) @grammar.declare_precedence :Nonassoc, syms.map {|s| @grammar.intern(s)} end |
#right(*syms) ⇒ Object
398 399 400 |
# File 'lib/racc/grammar.rb', line 398 def right(*syms) @grammar.declare_precedence :Right, syms.map {|s| @grammar.intern(s) } end |