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 974
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 1009
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 1064
attr_accessor :assoc
#dummy? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/racc/grammar.rb', line 1027
def dummy? @dummyp end
#expand (readonly)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1101
attr_reader :
#hash (readonly)
Alias for #ident.
# File 'lib/racc/grammar.rb', line 1023
alias hash ident
#heads (readonly)
cache
# File 'lib/racc/grammar.rb', line 1084
attr_reader :heads
#ident (readonly) Also known as: #hash
[ GitHub ]# File 'lib/racc/grammar.rb', line 1021
attr_reader :ident
#locate (readonly)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1085
attr_reader :locate
#nonterminal? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/racc/grammar.rb', line 1035
def nonterminal? @nterm end
#null=(n) (writeonly)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1097
def null=(n) @null = n end
#nullable? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/racc/grammar.rb', line 1093
def nullable? @null end
#precedence (rw)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1063
attr_accessor :precedence
#self_null? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/racc/grammar.rb', line 1087
def self_null? @snull end
#serialized=(value) (writeonly)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1061
attr_writer :serialized
#should_terminal (readonly)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1045
def should_terminal @should_terminal = true end
#should_terminal? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/racc/grammar.rb', line 1049
def should_terminal? @should_terminal end
#string_symbol? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/racc/grammar.rb', line 1053
def string_symbol? @string end
#term=(t) (writeonly)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1039
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 1031
def terminal? @term end
#useless=(f) (rw)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1108
def useless=(f) @useless = f end
#useless? ⇒ Boolean
(rw)
[ GitHub ]
# File 'lib/racc/grammar.rb', line 1104
def useless? @useless end
#value (readonly)
[ GitHub ]# File 'lib/racc/grammar.rb', line 1025
attr_reader :value
Instance Method Details
#inspect
Alias for #to_s.
# File 'lib/racc/grammar.rb', line 1070
alias inspect to_s
#rule
[ GitHub ]# File 'lib/racc/grammar.rb', line 1076
def rule Rule.new(nil, [self], UserAction.empty) end
#serialize
[ GitHub ]# File 'lib/racc/grammar.rb', line 1057
def serialize @serialized end
#to_s Also known as: #inspect
[ GitHub ]# File 'lib/racc/grammar.rb', line 1066
def to_s @to_s.dup end