Class: Token

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

Overview

Note:

This class is used to represent a token

Token class for Melissa Converter NG

Author:

Version:

  • 1.0.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, value, position) ⇒ Token

Returns a new instance of Token.



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

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

Instance Attribute Details

#positionObject

Returns the value of attribute position.



8
9
10
# File 'lib/token.rb', line 8

def position
  @position
end

#typeObject

Returns the value of attribute type.



8
9
10
# File 'lib/token.rb', line 8

def type
  @type
end

#valueObject

Returns the value of attribute value.



8
9
10
# File 'lib/token.rb', line 8

def value
  @value
end

Class Method Details

.create(str) ⇒ Object



22
23
24
# File 'lib/token.rb', line 22

def self.create str
  Token.new(:id, str, [0, 0])
end

Instance Method Details

#accept(visitor) ⇒ Object



20
# File 'lib/token.rb', line 20

def accept visitor; end

#is_a?(type) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/token.rb', line 16

def is_a? type
  @type == type
end

#to_sObject



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

def to_s
  "#{@type} : #{@value}"
end