Class: Token

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

Constant Summary collapse

VAR =

variable

0
SET =

set var =

1
ADD =

append var +=

2
TAR =

target

3
WS =

whitespace

4
CMD =

commang

5
LAB =

label

6
VAL =

value

7
PLAT =

platform

8
9
LBR =

linebreak

10
EOF =
9999

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, lexeme, line) ⇒ Token

Returns a new instance of Token.



19
20
21
22
23
# File 'lib/xmk/token.rb', line 19

def initialize(type, lexeme, line)
  @type = type
  @lexeme = lexeme
  @line = line
end

Instance Attribute Details

#lexemeObject (readonly)

Returns the value of attribute lexeme.



2
3
4
# File 'lib/xmk/token.rb', line 2

def lexeme
  @lexeme
end

#lineObject (readonly)

Returns the value of attribute line.



2
3
4
# File 'lib/xmk/token.rb', line 2

def line
  @line
end

#literalObject (readonly)

Returns the value of attribute literal.



2
3
4
# File 'lib/xmk/token.rb', line 2

def literal
  @literal
end

#typeObject (readonly)

Returns the value of attribute type.



2
3
4
# File 'lib/xmk/token.rb', line 2

def type
  @type
end

Instance Method Details

#to_sObject



25
26
27
# File 'lib/xmk/token.rb', line 25

def to_s
  "#{@type} #{@lexeme} #{@line}"
end