class Racc::Rule
Attributes
Public Class Methods
Source
# File lib/racc/grammar.rb, line 610 def initialize(target, syms, act) @target = target @symbols = syms @action = act @alternatives = [] @ident = nil @hash = nil @ptrs = nil @precedence = nil @specified_prec = nil @null = nil @useless = nil end
Public Instance Methods
Source
# File lib/racc/grammar.rb, line 689 def ==(other) other.kind_of?(Rule) and @ident == other.ident end
Source
# File lib/racc/grammar.rb, line 709 def accept? if tok = @symbols[-1] tok.anchor? else false end end
Source
# File lib/racc/grammar.rb, line 717 def each(&block) @symbols.each(&block) end
Source
# File lib/racc/grammar.rb, line 638 def each_rule(&block) yield self @alternatives.each(&block) end
Source
# File lib/racc/grammar.rb, line 648 def hash=(n) @hash = n ptrs = [] @symbols.each_with_index do |sym, idx| ptrs.push LocationPointer.new(self, idx, sym) end ptrs.push LocationPointer.new(self, @symbols.size, nil) @ptrs = ptrs end
Source
# File lib/racc/grammar.rb, line 685 def inspect "#<Racc::Rule id=#{@ident} (#{@target})>" end
Source
# File lib/racc/grammar.rb, line 666 def prec(sym, &block) @specified_prec = sym if block unless @action.empty? raise CompileError, 'both of rule action block and prec block given' end @action = UserAction.proc(block) end self end
Source
# File lib/racc/grammar.rb, line 658 def precedence @specified_prec || @precedence end
Source
# File lib/racc/grammar.rb, line 662 def precedence=(sym) @precedence ||= sym end
Source
# File lib/racc/grammar.rb, line 721 def replace(src, dest) @target = dest @symbols = @symbols.map {|s| s == src ? dest : s } end