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 361

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 368

attr_reader :reverse

Instance Method Details

#higher

[ GitHub ]

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

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

#left(*syms)

[ GitHub ]

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

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

#lower

[ GitHub ]

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

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 395

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

#right(*syms)

[ GitHub ]

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

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