Class: Dhaka::Token
- Inherits:
-
Object
- Object
- Dhaka::Token
- Defined in:
- lib/parser/token.rb
Overview
Represents a portion of the input character stream that is mapped by the tokenizer to a symbol in the grammar.
Instance Attribute Summary collapse
-
#grammar_symbol ⇒ Object
Returns the value of attribute grammar_symbol.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(grammar_symbol, value) ⇒ Token
constructor
A new instance of Token.
- #to_s ⇒ Object
Constructor Details
#initialize(grammar_symbol, value) ⇒ Token
Returns a new instance of Token.
6 7 8 9 |
# File 'lib/parser/token.rb', line 6 def initialize(grammar_symbol, value) @grammar_symbol = grammar_symbol @value = value end |
Instance Attribute Details
#grammar_symbol ⇒ Object
Returns the value of attribute grammar_symbol.
5 6 7 |
# File 'lib/parser/token.rb', line 5 def grammar_symbol @grammar_symbol end |
#value ⇒ Object
Returns the value of attribute value.
5 6 7 |
# File 'lib/parser/token.rb', line 5 def value @value end |
Instance Method Details
#==(other) ⇒ Object
13 14 15 |
# File 'lib/parser/token.rb', line 13 def == other (grammar_symbol == other.grammar_symbol) && (value == other.value) end |
#to_s ⇒ Object
10 11 12 |
# File 'lib/parser/token.rb', line 10 def to_s "#{@grammar_symbol.name}" end |