Class: Lrama::Grammar::Symbol
- Inherits:
-
Struct
- Object
- Struct
- Lrama::Grammar::Symbol
- Defined in:
- lib/lrama/grammar/symbol.rb
Instance Attribute Summary collapse
-
#accept_symbol ⇒ Object
writeonly
Sets the attribute accept_symbol.
-
#alias_name ⇒ Object
Returns the value of attribute alias_name.
-
#eof_symbol ⇒ Object
writeonly
Sets the attribute eof_symbol.
-
#error_symbol ⇒ Object
writeonly
Sets the attribute error_symbol.
-
#error_token ⇒ Object
Returns the value of attribute error_token.
-
#first_set ⇒ Object
Returns the value of attribute first_set.
-
#first_set_bitmap ⇒ Object
Returns the value of attribute first_set_bitmap.
-
#id ⇒ Object
Returns the value of attribute id.
-
#nullable ⇒ Object
Returns the value of attribute nullable.
-
#number ⇒ Object
Returns the value of attribute number.
-
#precedence ⇒ Object
Returns the value of attribute precedence.
-
#printer ⇒ Object
Returns the value of attribute printer.
-
#tag ⇒ Object
Returns the value of attribute tag.
-
#term ⇒ Object
Returns the value of attribute term.
-
#token_id ⇒ Object
Returns the value of attribute token_id.
-
#undef_symbol ⇒ Object
writeonly
Sets the attribute undef_symbol.
Instance Method Summary collapse
- #accept_symbol? ⇒ Boolean
-
#comment ⇒ Object
comment for yysymbol_kind_t.
- #display_name ⇒ Object
-
#enum_name ⇒ Object
name for yysymbol_kind_t.
- #eof_symbol? ⇒ Boolean
- #error_symbol? ⇒ Boolean
- #nterm? ⇒ Boolean
- #term? ⇒ Boolean
- #undef_symbol? ⇒ Boolean
Instance Attribute Details
#accept_symbol=(value) ⇒ Object (writeonly)
Sets the attribute accept_symbol
11 12 13 |
# File 'lib/lrama/grammar/symbol.rb', line 11 def accept_symbol=(value) @accept_symbol = value end |
#alias_name ⇒ Object
Returns the value of attribute alias_name
9 10 11 |
# File 'lib/lrama/grammar/symbol.rb', line 9 def alias_name @alias_name end |
#eof_symbol=(value) ⇒ Object (writeonly)
Sets the attribute eof_symbol
11 12 13 |
# File 'lib/lrama/grammar/symbol.rb', line 11 def eof_symbol=(value) @eof_symbol = value end |
#error_symbol=(value) ⇒ Object (writeonly)
Sets the attribute error_symbol
11 12 13 |
# File 'lib/lrama/grammar/symbol.rb', line 11 def error_symbol=(value) @error_symbol = value end |
#error_token ⇒ Object
Returns the value of attribute error_token
9 10 11 |
# File 'lib/lrama/grammar/symbol.rb', line 9 def error_token @error_token end |
#first_set ⇒ Object
Returns the value of attribute first_set.
10 11 12 |
# File 'lib/lrama/grammar/symbol.rb', line 10 def first_set @first_set end |
#first_set_bitmap ⇒ Object
Returns the value of attribute first_set_bitmap.
10 11 12 |
# File 'lib/lrama/grammar/symbol.rb', line 10 def first_set_bitmap @first_set_bitmap end |
#id ⇒ Object
Returns the value of attribute id
9 10 11 |
# File 'lib/lrama/grammar/symbol.rb', line 9 def id @id end |
#nullable ⇒ Object
Returns the value of attribute nullable
9 10 11 |
# File 'lib/lrama/grammar/symbol.rb', line 9 def nullable @nullable end |
#number ⇒ Object
Returns the value of attribute number
9 10 11 |
# File 'lib/lrama/grammar/symbol.rb', line 9 def number @number end |
#precedence ⇒ Object
Returns the value of attribute precedence
9 10 11 |
# File 'lib/lrama/grammar/symbol.rb', line 9 def precedence @precedence end |
#printer ⇒ Object
Returns the value of attribute printer
9 10 11 |
# File 'lib/lrama/grammar/symbol.rb', line 9 def printer @printer end |
#tag ⇒ Object
Returns the value of attribute tag
9 10 11 |
# File 'lib/lrama/grammar/symbol.rb', line 9 def tag @tag end |
#term ⇒ Object
Returns the value of attribute term
9 10 11 |
# File 'lib/lrama/grammar/symbol.rb', line 9 def term @term end |
#token_id ⇒ Object
Returns the value of attribute token_id
9 10 11 |
# File 'lib/lrama/grammar/symbol.rb', line 9 def token_id @token_id end |
#undef_symbol=(value) ⇒ Object (writeonly)
Sets the attribute undef_symbol
11 12 13 |
# File 'lib/lrama/grammar/symbol.rb', line 11 def undef_symbol=(value) @undef_symbol = value end |
Instance Method Details
#accept_symbol? ⇒ Boolean
33 34 35 |
# File 'lib/lrama/grammar/symbol.rb', line 33 def accept_symbol? !!@accept_symbol end |
#comment ⇒ Object
comment for yysymbol_kind_t
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/lrama/grammar/symbol.rb', line 66 def comment case when accept_symbol? # YYSYMBOL_YYACCEPT id.s_value when eof_symbol? # YYEOF alias_name when (term? && 0 < token_id && token_id < 128) # YYSYMBOL_3_backslash_, YYSYMBOL_14_ alias_name || id.s_value when id.s_value.include?("$") || id.s_value.include?("@") # YYSYMBOL_21_1 id.s_value else # YYSYMBOL_keyword_class, YYSYMBOL_strings_1 alias_name || id.s_value end end |
#display_name ⇒ Object
37 38 39 |
# File 'lib/lrama/grammar/symbol.rb', line 37 def display_name alias_name || id.s_value end |
#enum_name ⇒ Object
name for yysymbol_kind_t
See: b4_symbol_kind_base
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/lrama/grammar/symbol.rb', line 44 def enum_name case when accept_symbol? name = "YYACCEPT" when eof_symbol? name = "YYEOF" when term? && id.type == Token::Char name = number.to_s + display_name when term? && id.type == Token::Ident name = id.s_value when nterm? && (id.s_value.include?("$") || id.s_value.include?("@")) name = number.to_s + id.s_value when nterm? name = id.s_value else raise "Unexpected #{self}" end "YYSYMBOL_" + name.gsub(/\W+/, "_") end |
#eof_symbol? ⇒ Boolean
21 22 23 |
# File 'lib/lrama/grammar/symbol.rb', line 21 def eof_symbol? !!@eof_symbol end |
#error_symbol? ⇒ Boolean
25 26 27 |
# File 'lib/lrama/grammar/symbol.rb', line 25 def error_symbol? !!@error_symbol end |
#nterm? ⇒ Boolean
17 18 19 |
# File 'lib/lrama/grammar/symbol.rb', line 17 def nterm? !term end |
#term? ⇒ Boolean
13 14 15 |
# File 'lib/lrama/grammar/symbol.rb', line 13 def term? term end |
#undef_symbol? ⇒ Boolean
29 30 31 |
# File 'lib/lrama/grammar/symbol.rb', line 29 def undef_symbol? !!@undef_symbol end |