Class: Dhaka::GrammarSymbol
- Inherits:
-
Object
- Object
- Dhaka::GrammarSymbol
- Defined in:
- lib/dhaka/grammar/grammar_symbol.rb
Overview
Each grammar symbol is uniquely identified by a string name. The name of a symbol can be anything (except the two reserved names '_Start_'
and '_End_'
) and need not correspond to its character representation. For example, an ampersand in the input string could be tokenized as a symbol with a name ‘AND_OP’. You never have to directly instantiate a GrammarSymbol. It is done implicitly for you when you define a Grammar.
Instance Attribute Summary collapse
-
#associativity ⇒ Object
Returns the value of attribute associativity.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#non_terminal ⇒ Object
Returns the value of attribute non_terminal.
-
#nullable ⇒ Object
Returns the value of attribute nullable.
-
#precedence ⇒ Object
Returns the value of attribute precedence.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(name) ⇒ GrammarSymbol
constructor
A new instance of GrammarSymbol.
- #terminal ⇒ Object
-
#to_s ⇒ Object
:nodoc:.
Constructor Details
#initialize(name) ⇒ GrammarSymbol
Returns a new instance of GrammarSymbol.
11 12 13 |
# File 'lib/dhaka/grammar/grammar_symbol.rb', line 11 def initialize(name) @name = name end |
Instance Attribute Details
#associativity ⇒ Object
Returns the value of attribute associativity.
9 10 11 |
# File 'lib/dhaka/grammar/grammar_symbol.rb', line 9 def associativity @associativity end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/dhaka/grammar/grammar_symbol.rb', line 8 def name @name end |
#non_terminal ⇒ Object
Returns the value of attribute non_terminal.
9 10 11 |
# File 'lib/dhaka/grammar/grammar_symbol.rb', line 9 def non_terminal @non_terminal end |
#nullable ⇒ Object
Returns the value of attribute nullable.
9 10 11 |
# File 'lib/dhaka/grammar/grammar_symbol.rb', line 9 def nullable @nullable end |
#precedence ⇒ Object
Returns the value of attribute precedence.
9 10 11 |
# File 'lib/dhaka/grammar/grammar_symbol.rb', line 9 def precedence @precedence end |
Instance Method Details
#<=>(other) ⇒ Object
23 24 25 |
# File 'lib/dhaka/grammar/grammar_symbol.rb', line 23 def <=> other name <=> other.name end |
#terminal ⇒ Object
15 16 17 |
# File 'lib/dhaka/grammar/grammar_symbol.rb', line 15 def terminal !non_terminal end |
#to_s ⇒ Object
:nodoc:
19 20 21 |
# File 'lib/dhaka/grammar/grammar_symbol.rb', line 19 def to_s #:nodoc: name.dup end |