Class: Racc::Sym
Overview
Stands terminal and nonterminal symbols.
Instance Attribute Summary collapse
-
#assoc ⇒ Object
Returns the value of attribute assoc.
-
#expand ⇒ Object
readonly
Returns the value of attribute expand.
-
#heads ⇒ Object
readonly
cache.
-
#ident ⇒ Object
(also: #hash)
readonly
Returns the value of attribute ident.
-
#locate ⇒ Object
readonly
Returns the value of attribute locate.
-
#precedence ⇒ Object
Returns the value of attribute precedence.
-
#serialized ⇒ Object
writeonly
Sets the attribute serialized.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #dummy? ⇒ Boolean
-
#initialize(value, dummyp) ⇒ Sym
constructor
A new instance of Sym.
- #nonterminal? ⇒ Boolean
- #null=(n) ⇒ Object
- #nullable? ⇒ Boolean
- #rule ⇒ Object
- #self_null? ⇒ Boolean
- #serialize ⇒ Object
- #should_terminal ⇒ Object
- #should_terminal? ⇒ Boolean
- #string_symbol? ⇒ Boolean
- #term=(t) ⇒ Object
- #terminal? ⇒ Boolean
- #to_s ⇒ Object (also: #inspect)
- #useless=(f) ⇒ Object
- #useless? ⇒ Boolean
- #|(x) ⇒ Object
Constructor Details
#initialize(value, dummyp) ⇒ Sym
Returns a new instance of Sym.
969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 |
# 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 |
Instance Attribute Details
#assoc ⇒ Object
Returns the value of attribute assoc.
1063 1064 1065 |
# File 'lib/racc/grammar.rb', line 1063 def assoc @assoc end |
#expand ⇒ Object (readonly)
Returns the value of attribute expand.
1100 1101 1102 |
# File 'lib/racc/grammar.rb', line 1100 def @expand end |
#heads ⇒ Object (readonly)
cache
1083 1084 1085 |
# File 'lib/racc/grammar.rb', line 1083 def heads @heads end |
#ident ⇒ Object (readonly) Also known as: hash
Returns the value of attribute ident.
1020 1021 1022 |
# File 'lib/racc/grammar.rb', line 1020 def ident @ident end |
#locate ⇒ Object (readonly)
Returns the value of attribute locate.
1084 1085 1086 |
# File 'lib/racc/grammar.rb', line 1084 def locate @locate end |
#precedence ⇒ Object
Returns the value of attribute precedence.
1062 1063 1064 |
# File 'lib/racc/grammar.rb', line 1062 def precedence @precedence end |
#serialized=(value) ⇒ Object (writeonly)
Sets the attribute serialized
1060 1061 1062 |
# File 'lib/racc/grammar.rb', line 1060 def serialized=(value) @serialized = value end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
1024 1025 1026 |
# File 'lib/racc/grammar.rb', line 1024 def value @value end |
Class Method Details
.once_writer(nm) ⇒ Object
1008 1009 1010 1011 1012 1013 1014 1015 1016 |
# 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 Method Details
#dummy? ⇒ Boolean
1026 1027 1028 |
# File 'lib/racc/grammar.rb', line 1026 def dummy? @dummyp end |
#nonterminal? ⇒ Boolean
1034 1035 1036 |
# File 'lib/racc/grammar.rb', line 1034 def nonterminal? @nterm end |
#null=(n) ⇒ Object
1096 1097 1098 |
# File 'lib/racc/grammar.rb', line 1096 def null=(n) @null = n end |
#nullable? ⇒ Boolean
1092 1093 1094 |
# File 'lib/racc/grammar.rb', line 1092 def nullable? @null end |
#rule ⇒ Object
1075 1076 1077 |
# File 'lib/racc/grammar.rb', line 1075 def rule Rule.new(nil, [self], UserAction.empty) end |
#self_null? ⇒ Boolean
1086 1087 1088 |
# File 'lib/racc/grammar.rb', line 1086 def self_null? @snull end |
#serialize ⇒ Object
1056 1057 1058 |
# File 'lib/racc/grammar.rb', line 1056 def serialize @serialized end |
#should_terminal ⇒ Object
1044 1045 1046 |
# File 'lib/racc/grammar.rb', line 1044 def should_terminal @should_terminal = true end |
#should_terminal? ⇒ Boolean
1048 1049 1050 |
# File 'lib/racc/grammar.rb', line 1048 def should_terminal? @should_terminal end |
#string_symbol? ⇒ Boolean
1052 1053 1054 |
# File 'lib/racc/grammar.rb', line 1052 def string_symbol? @string end |
#term=(t) ⇒ Object
1038 1039 1040 1041 1042 |
# 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
1030 1031 1032 |
# File 'lib/racc/grammar.rb', line 1030 def terminal? @term end |
#to_s ⇒ Object Also known as: inspect
1065 1066 1067 |
# File 'lib/racc/grammar.rb', line 1065 def to_s @to_s.dup end |
#useless=(f) ⇒ Object
1107 1108 1109 |
# File 'lib/racc/grammar.rb', line 1107 def useless=(f) @useless = f end |
#useless? ⇒ Boolean
1103 1104 1105 |
# File 'lib/racc/grammar.rb', line 1103 def useless? @useless end |
#|(x) ⇒ Object
1071 1072 1073 |
# File 'lib/racc/grammar.rb', line 1071 def |(x) rule() | x.rule end |