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

- (Token) initialize(type, value, source_line)

Returns a new instance of Token

Parameters:



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

- (Object) source_line (readonly)

Returns the value of attribute source_line



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

def source_line
  @source_line
end

- (Object) type (readonly)

Returns the value of attribute type



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

def type
  @type
end

- (Object) value (readonly)

Returns the value of attribute value



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

def value
  @value
end

Instance Method Details

- (TrueClass|FalseClass) ==(other)

Returns:

  • (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