Class: Racc::Sym
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/racc/grammar.rb |
Overview
Stands terminal and nonterminal symbols.
Class Method Summary
- .new(value, dummyp) ⇒ Sym constructor
- .once_writer(nm)
Instance Attribute Summary
- #assoc rw
- #dummy? ⇒ Boolean readonly
- #expand readonly
-
#hash
readonly
Alias for #ident.
-
#heads
readonly
cache.
- #ident (also: #hash) readonly
- #locate readonly
- #nonterminal? ⇒ Boolean readonly
- #null=(n) writeonly
- #nullable? ⇒ Boolean readonly
- #precedence rw
- #self_null? ⇒ Boolean readonly
- #serialized=(value) writeonly
- #should_terminal readonly
- #should_terminal? ⇒ Boolean readonly
- #string_symbol? ⇒ Boolean readonly
- #term=(t) writeonly
- #terminal? ⇒ Boolean readonly
- #useless=(f) rw
- #useless? ⇒ Boolean rw
- #value readonly
Instance Method Summary
Constructor Details
.new(value, dummyp) ⇒ Sym
# File 'lib/racc/grammar.rb', line 969
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 when ErrorSymbolValue @to_s = 'error' @serialized = 'Object.new' @string = false else raise ArgumentError, "unknown symbol value: #{value.class}" end @heads = [] @locate = [] @snull = nil @null = nil @expand = nil @useless = nil end
Class Method Details
.once_writer(nm)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1008
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
Instance Attribute Details
#assoc (rw)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1063
attr_accessor :assoc
#dummy? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/racc/grammar.rb', line 1026
def dummy? @dummyp end
#expand (readonly)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1100
attr_reader :
#hash (readonly)
Alias for #ident.
# File 'lib/racc/grammar.rb', line 1022
alias hash ident
#heads (readonly)
cache
# File 'lib/racc/grammar.rb', line 1083
attr_reader :heads
#ident (readonly) Also known as: #hash
[ GitHub ]# File 'lib/racc/grammar.rb', line 1020
attr_reader :ident
#locate (readonly)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1084
attr_reader :locate
#nonterminal? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/racc/grammar.rb', line 1034
def nonterminal? @nterm end
#null=(n) (writeonly)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1096
def null=(n) @null = n end
#nullable? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/racc/grammar.rb', line 1092
def nullable? @null end
#precedence (rw)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1062
attr_accessor :precedence
#self_null? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/racc/grammar.rb', line 1086
def self_null? @snull end
#serialized=(value) (writeonly)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1060
attr_writer :serialized
#should_terminal (readonly)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1044
def should_terminal @should_terminal = true end
#should_terminal? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/racc/grammar.rb', line 1048
def should_terminal? @should_terminal end
#string_symbol? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/racc/grammar.rb', line 1052
def string_symbol? @string end
#term=(t) (writeonly)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1038
def term=(t) raise 'racc: fatal: term= called twice' unless @term.nil? @term = t @nterm = !t end
#terminal? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/racc/grammar.rb', line 1030
def terminal? @term end
#useless=(f) (rw)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1107
def useless=(f) @useless = f end
#useless? ⇒ Boolean
(rw)
[ GitHub ]
# File 'lib/racc/grammar.rb', line 1103
def useless? @useless end
#value (readonly)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1024
attr_reader :value
Instance Method Details
#inspect
Alias for #to_s.
# File 'lib/racc/grammar.rb', line 1069
alias inspect to_s
#rule
[ GitHub ]# File 'lib/racc/grammar.rb', line 1075
def rule Rule.new(nil, [self], UserAction.empty) end
#serialize
[ GitHub ]# File 'lib/racc/grammar.rb', line 1056
def serialize @serialized end
#to_s Also known as: #inspect
[ GitHub ]# File 'lib/racc/grammar.rb', line 1065
def to_s @to_s.dup end