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 1051
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
Class Method Details
.once_writer(nm)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1086
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 1141
attr_accessor :assoc
#dummy? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/racc/grammar.rb', line 1104
def dummy? @dummyp end
#expand (readonly)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1178
attr_reader :
#hash (readonly)
Alias for #ident.
# File 'lib/racc/grammar.rb', line 1100
alias hash ident
#heads (readonly)
cache
# File 'lib/racc/grammar.rb', line 1161
attr_reader :heads
#ident (readonly) Also known as: #hash
[ GitHub ]# File 'lib/racc/grammar.rb', line 1098
attr_reader :ident
#locate (readonly)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1162
attr_reader :locate
#nonterminal? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/racc/grammar.rb', line 1112
def nonterminal? @nterm end
#null=(n) (writeonly)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1174
def null=(n) @null = n end
#nullable? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/racc/grammar.rb', line 1170
def nullable? @null end
#precedence (rw)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1140
attr_accessor :precedence
#self_null? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/racc/grammar.rb', line 1164
def self_null? @snull end
#serialized=(value) (writeonly)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1138
attr_writer :serialized
#should_terminal (readonly)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1122
def should_terminal @should_terminal = true end
#should_terminal? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/racc/grammar.rb', line 1126
def should_terminal? @should_terminal end
#string_symbol? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/racc/grammar.rb', line 1130
def string_symbol? @string end
#term=(t) (writeonly)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1116
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 1108
def terminal? @term end
#useless=(f) (rw)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1185
def useless=(f) @useless = f end
#useless? ⇒ Boolean
(rw)
[ GitHub ]
# File 'lib/racc/grammar.rb', line 1181
def useless? @useless end
#value (readonly)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1102
attr_reader :value
Instance Method Details
#inspect
Alias for #to_s.
# File 'lib/racc/grammar.rb', line 1147
alias inspect to_s
#rule
[ GitHub ]# File 'lib/racc/grammar.rb', line 1153
def rule Rule.new(nil, [self], UserAction.empty) end
#serialize
[ GitHub ]# File 'lib/racc/grammar.rb', line 1134
def serialize @serialized end
#to_s Also known as: #inspect
[ GitHub ]# File 'lib/racc/grammar.rb', line 1143
def to_s @to_s.dup end