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. The attribute input_position
contains the start index position of the original string input that this token came from. It can be used to report errors by indicating the specific portion of the input where the error occurred.
Instance Attribute Summary collapse
-
#input_position ⇒ Object
Returns the value of attribute input_position.
-
#symbol_name ⇒ Object
Returns the value of attribute symbol_name.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(symbol_name, value, input_position) ⇒ Token
constructor
A new instance of Token.
-
#to_s ⇒ Object
:nodoc:.
Constructor Details
#initialize(symbol_name, value, input_position) ⇒ Token
Returns a new instance of Token.
8 9 10 11 12 |
# File 'lib/parser/token.rb', line 8 def initialize(symbol_name, value, input_position) @symbol_name = symbol_name @value = value @input_position = input_position end |
Instance Attribute Details
#input_position ⇒ Object
Returns the value of attribute input_position.
7 8 9 |
# File 'lib/parser/token.rb', line 7 def input_position @input_position end |
#symbol_name ⇒ Object
Returns the value of attribute symbol_name.
7 8 9 |
# File 'lib/parser/token.rb', line 7 def symbol_name @symbol_name end |
#value ⇒ Object
Returns the value of attribute value.
7 8 9 |
# File 'lib/parser/token.rb', line 7 def value @value end |
Instance Method Details
#==(other) ⇒ Object
16 17 18 |
# File 'lib/parser/token.rb', line 16 def == other (symbol_name == other.symbol_name) && (value == other.value) end |
#to_s ⇒ Object
:nodoc:
13 14 15 |
# File 'lib/parser/token.rb', line 13 def to_s #:nodoc: "#{symbol_name}" end |