Class: Dhaka::GrammarSymbol
- Inherits:
-
Object
- Object
- Dhaka::GrammarSymbol
- Defined in:
- lib/grammar/grammar_symbol.rb
Overview
Each grammar symbol is uniquely identified by a string name. The name of a symbol can be anything and need not correspond to its character representation. For example, an ampersand in the character stream could be tokenized as a symbol with a name ‘whatever’. In general, it’s best to choose symbol names that are descriptive.
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.
10 11 12 |
# File 'lib/grammar/grammar_symbol.rb', line 10 def initialize(name) @name = name end |
Instance Attribute Details
#associativity ⇒ Object
Returns the value of attribute associativity.
9 10 11 |
# File 'lib/grammar/grammar_symbol.rb', line 9 def associativity @associativity end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/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/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/grammar/grammar_symbol.rb', line 9 def nullable @nullable end |
#precedence ⇒ Object
Returns the value of attribute precedence.
9 10 11 |
# File 'lib/grammar/grammar_symbol.rb', line 9 def precedence @precedence end |
Instance Method Details
#<=>(other) ⇒ Object
19 20 21 |
# File 'lib/grammar/grammar_symbol.rb', line 19 def <=> other self.name <=> other.name end |
#terminal ⇒ Object
13 14 15 |
# File 'lib/grammar/grammar_symbol.rb', line 13 def terminal !non_terminal end |
#to_s ⇒ Object
:nodoc:
16 17 18 |
# File 'lib/grammar/grammar_symbol.rb', line 16 def to_s #:nodoc: name end |