class Racc::Rule
def ==(other)
def ==(other) other.kind_of?(Rule) and @ident == other.ident end
def [](idx)
def [](idx) @symbols[idx] end
def accept?
def accept? if tok = @symbols[-1] tok.anchor? else false end end
def each(&block)
def each(&block) @symbols.each(&block) end
def each_rule(&block)
def each_rule(&block) yield self @alternatives.each(&block) end
def empty?
def empty? @symbols.empty? end
def hash=(n)
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
def initialize(target, syms, act)
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
def inspect
def inspect "#<Racc::Rule id=#{@ident} (#{@target})>" end
def null=(n) @null = n end
def null=(n) @null = n end
def nullable?() @null end
def nullable?() @null end
def prec(sym, &block)
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
def precedence
def precedence @specified_prec || @precedence end
def precedence=(sym)
def precedence=(sym) @precedence ||= sym end
def replace(src, dest)
def replace(src, dest) @target = dest @symbols = @symbols.map {|s| s == src ? dest : s } end
def rule
def rule self end
def size
def size @symbols.size end
def to_s
def to_s "#<rule#{@ident}>" end
def useless=(u) @useless = u end
def useless=(u) @useless = u end
def useless?() @useless end
def useless?() @useless end
def |(x)
def |(x) @alternatives.push x.rule self end