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.
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 1006 1007 1008 1009 1010 |
# 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 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.
1068 1069 1070 |
# File 'lib/racc/grammar.rb', line 1068 def assoc @assoc end |
#expand ⇒ Object (readonly)
Returns the value of attribute expand.
1105 1106 1107 |
# File 'lib/racc/grammar.rb', line 1105 def @expand end |
#heads ⇒ Object (readonly)
cache
1088 1089 1090 |
# File 'lib/racc/grammar.rb', line 1088 def heads @heads end |
#ident ⇒ Object (readonly) Also known as: hash
Returns the value of attribute ident.
1025 1026 1027 |
# File 'lib/racc/grammar.rb', line 1025 def ident @ident end |
#locate ⇒ Object (readonly)
Returns the value of attribute locate.
1089 1090 1091 |
# File 'lib/racc/grammar.rb', line 1089 def locate @locate end |
#precedence ⇒ Object
Returns the value of attribute precedence.
1067 1068 1069 |
# File 'lib/racc/grammar.rb', line 1067 def precedence @precedence end |
#serialized=(value) ⇒ Object (writeonly)
Sets the attribute serialized
1065 1066 1067 |
# File 'lib/racc/grammar.rb', line 1065 def serialized=(value) @serialized = value end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
1029 1030 1031 |
# File 'lib/racc/grammar.rb', line 1029 def value @value end |
Class Method Details
.once_writer(nm) ⇒ Object
1013 1014 1015 1016 1017 1018 1019 1020 1021 |
# File 'lib/racc/grammar.rb', line 1013 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
1031 1032 1033 |
# File 'lib/racc/grammar.rb', line 1031 def dummy? @dummyp end |
#nonterminal? ⇒ Boolean
1039 1040 1041 |
# File 'lib/racc/grammar.rb', line 1039 def nonterminal? @nterm end |
#null=(n) ⇒ Object
1101 1102 1103 |
# File 'lib/racc/grammar.rb', line 1101 def null=(n) @null = n end |
#nullable? ⇒ Boolean
1097 1098 1099 |
# File 'lib/racc/grammar.rb', line 1097 def nullable? @null end |
#rule ⇒ Object
1080 1081 1082 |
# File 'lib/racc/grammar.rb', line 1080 def rule Rule.new(nil, [self], UserAction.empty) end |
#self_null? ⇒ Boolean
1091 1092 1093 |
# File 'lib/racc/grammar.rb', line 1091 def self_null? @snull end |
#serialize ⇒ Object
1061 1062 1063 |
# File 'lib/racc/grammar.rb', line 1061 def serialize @serialized end |
#should_terminal ⇒ Object
1049 1050 1051 |
# File 'lib/racc/grammar.rb', line 1049 def should_terminal @should_terminal = true end |
#should_terminal? ⇒ Boolean
1053 1054 1055 |
# File 'lib/racc/grammar.rb', line 1053 def should_terminal? @should_terminal end |
#string_symbol? ⇒ Boolean
1057 1058 1059 |
# File 'lib/racc/grammar.rb', line 1057 def string_symbol? @string end |
#term=(t) ⇒ Object
1043 1044 1045 1046 1047 |
# File 'lib/racc/grammar.rb', line 1043 def term=(t) raise 'racc: fatal: term= called twice' unless @term.nil? @term = t @nterm = !t end |
#terminal? ⇒ Boolean
1035 1036 1037 |
# File 'lib/racc/grammar.rb', line 1035 def terminal? @term end |
#to_s ⇒ Object Also known as: inspect
1070 1071 1072 |
# File 'lib/racc/grammar.rb', line 1070 def to_s @to_s.dup end |
#useless=(f) ⇒ Object
1112 1113 1114 |
# File 'lib/racc/grammar.rb', line 1112 def useless=(f) @useless = f end |
#useless? ⇒ Boolean
1108 1109 1110 |
# File 'lib/racc/grammar.rb', line 1108 def useless? @useless end |
#|(x) ⇒ Object
1076 1077 1078 |
# File 'lib/racc/grammar.rb', line 1076 def |(x) rule() | x.rule end |