Class: Deadfire::FrontEnd::Token

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, lexeme, literal, lineno) ⇒ Token

Returns a new instance of Token.



8
9
10
11
12
13
# File 'lib/deadfire/front_end/token.rb', line 8

def initialize(type, lexeme, literal, lineno)
  @type = type
  @lexeme = lexeme
  @literal = literal
  @lineno = lineno
end

Instance Attribute Details

#lexemeObject (readonly)

Returns the value of attribute lexeme.



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

def lexeme
  @lexeme
end

#linenoObject (readonly)

Returns the value of attribute lineno.



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

def lineno
  @lineno
end

#literalObject (readonly)

Returns the value of attribute literal.



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

def literal
  @literal
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#to_sObject



15
16
17
# File 'lib/deadfire/front_end/token.rb', line 15

def to_s
  "[:#{type}] #{lexeme}"
end