Class: Racc::Grammar::PrecedenceDefinitionEnv

Inherits:
Object
  • Object
show all
Defined in:
lib/racc/grammar.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(g) ⇒ PrecedenceDefinitionEnv

Returns a new instance of PrecedenceDefinitionEnv.


363
364
365
366
367
368
# File 'lib/racc/grammar.rb', line 363

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

Instance Attribute Details

#reverseObject (readonly)

Returns the value of attribute reverse


370
371
372
# File 'lib/racc/grammar.rb', line 370

def reverse
  @reverse
end

Instance Method Details

#higherObject


372
373
374
375
376
377
# File 'lib/racc/grammar.rb', line 372

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

#left(*syms) ⇒ Object


389
390
391
# File 'lib/racc/grammar.rb', line 389

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

#lowerObject


379
380
381
382
383
384
385
386
387
# File 'lib/racc/grammar.rb', line 379

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

#nonassoc(*syms) ⇒ Object


397
398
399
# File 'lib/racc/grammar.rb', line 397

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

#right(*syms) ⇒ Object


393
394
395
# File 'lib/racc/grammar.rb', line 393

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