Class: LL::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/ll/token.rb

Overview

A Token contains the data of a single lexer token.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, value, source_line) ⇒ Token



13
14
15
16
17
# File 'lib/ll/token.rb', line 13

def initialize(type, value, source_line)
  @type        = type
  @value       = value
  @source_line = source_line
end

Instance Attribute Details

#source_lineObject (readonly)

Returns the value of attribute source_line.



6
7
8
# File 'lib/ll/token.rb', line 6

def source_line
  @source_line
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/ll/token.rb', line 6

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value.



6
7
8
# File 'lib/ll/token.rb', line 6

def value
  @value
end

Instance Method Details

#==(other) ⇒ TrueClass|FalseClass



22
23
24
25
26
27
28
# File 'lib/ll/token.rb', line 22

def ==(other)
  return false unless other.class == self.class

  return type == other.type &&
    value == other.value &&
    source_line == other.source_line
end