class Racc::Sym
Stands terminal and nonterminal symbols.
def dummy?
def dummy? @dummyp end
def initialize(value, dummyp)
def initialize(value, dummyp) @ident = nil @value = value @dummyp = dummyp @term = nil @nterm = nil @should_terminal = false @precedence = nil case value when Symbol @to_s = value.to_s @serialized = value.inspect @string = false when String @to_s = value.inspect @serialized = value.dump @string = true when false @to_s = '$end' @serialized = 'false' @string = false else raise ArgumentError, "unknown symbol value: #{value.class}" end @heads = [] @locate = [] @snull = nil @null = nil @expand = nil @useless = nil end
def nonterminal?
def nonterminal? @nterm end
def null=(n)
def null=(n) @null = n end
def nullable?
def nullable? @null end
def once_writer(nm)
def once_writer(nm) nm = nm.id2name module_eval(<<-EOS) def #{nm}=(v) raise 'racc: fatal: @#{nm} != nil' unless @#{nm}.nil? @#{nm} = v end EOS end
def rule
def rule Rule.new(nil, [self], UserAction.empty) end
def self_null?
def self_null? @snull end
def serialize
def serialize @serialized end
def should_terminal
def should_terminal @should_terminal = true end
def should_terminal?
def should_terminal? @should_terminal end
def string_symbol?
def string_symbol? @string end
def term=(t)
def term=(t) raise 'racc: fatal: term= called twice' unless @term.nil? @term = t @nterm = !t end
def terminal?
def terminal? @term end
def to_s
def to_s @to_s.dup end
def useless=(f)
def useless=(f) @useless = f end
def useless?
def useless? @useless end
def |(x)
def |(x) rule() | x.rule end