[](id)
click to toggle source
def [](id)
@symbols[id]
end
delete(sym)
click to toggle source
def delete(sym)
@symbols.delete sym
@cache.delete sym.value
end
each(&block)
click to toggle source
def each(&block)
@symbols.each(&block)
end
each_nonterminal(&block)
click to toggle source
def each_nonterminal(&block)
@nterms.each(&block)
end
each_terminal(&block)
click to toggle source
def each_terminal(&block)
@terms.each(&block)
end
fix()
click to toggle source
def fix
terms, nterms = @symbols.partition {|s| s.terminal? }
@symbols = terms + nterms
@terms = terms
@nterms = nterms
@nt_base = terms.size
fix_ident
check_terminals
end
intern(val, dummy = false)
click to toggle source
def intern(val, dummy = false)
@cache[val] ||=
begin
sym = Sym.new(val, dummy)
@symbols.push sym
sym
end
end
nonterminals()
click to toggle source
def nonterminals
@symbols[@nt_base, @symbols.size - @nt_base]
end
nt_max()
click to toggle source
def nt_max
@symbols.size
end
terminals(&block)
click to toggle source
def terminals(&block)
@symbols[0, @nt_base]
end