Class: Dhaka::Token

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_symbolObject

Returns the value of attribute grammar_symbol.



5
6
7
# File 'lib/parser/token.rb', line 5

def grammar_symbol
  @grammar_symbol
end

#valueObject

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_sObject



10
11
12
# File 'lib/parser/token.rb', line 10

def to_s
  "#{@grammar_symbol.name}"
end