Class: Kanocc::GrammarRule

Inherits:
Object
  • Object
show all
Defined in:
lib/kanocc/grammar_rule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lhs, rhs, method) ⇒ GrammarRule

Returns a new instance of GrammarRule.



24
25
26
27
28
29
30
# File 'lib/kanocc/grammar_rule.rb', line 24

def initialize(lhs, rhs, method)
  @lhs = lhs
  @rhs = rhs
  @method = method
  @prededence = 0
  @logger.debug("#{lhs} --> #{rhs.map {|gs| gs.is_a?(Symbol) ? gs.to_s : gs}.join}, #prec = #{@prec}, method = #{method}") if @logger
end

Instance Attribute Details

#derives_rightObject

Returns the value of attribute derives_right.



22
23
24
# File 'lib/kanocc/grammar_rule.rb', line 22

def derives_right
  @derives_right
end

#lhsObject (readonly)

Returns the value of attribute lhs.



21
22
23
# File 'lib/kanocc/grammar_rule.rb', line 21

def lhs
  @lhs
end

#methodObject (readonly)

Returns the value of attribute method.



21
22
23
# File 'lib/kanocc/grammar_rule.rb', line 21

def method
  @method
end

#precedenceObject

Returns the value of attribute precedence.



22
23
24
# File 'lib/kanocc/grammar_rule.rb', line 22

def precedence
  @precedence
end

#rhsObject (readonly)

Returns the value of attribute rhs.



21
22
23
# File 'lib/kanocc/grammar_rule.rb', line 21

def rhs
  @rhs
end

Instance Method Details

#inspectObject



32
33
34
# File 'lib/kanocc/grammar_rule.rb', line 32

def inspect 
  return lhs.inspect + " ::= " + rhs.map{|gs| gs.inspect}.join(" ")
end