Class: SystemRDL::Parser::Token

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, kind, position) ⇒ Token

Returns a new instance of Token.



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

def initialize(text, kind, position)
  @text = text
  @kind = kind
  @position = position
  freeze
end

Instance Attribute Details

#kindObject (readonly)

Returns the value of attribute kind.



31
32
33
# File 'lib/systemrdl/parser/token.rb', line 31

def kind
  @kind
end

#positionObject (readonly)

Returns the value of attribute position.



32
33
34
# File 'lib/systemrdl/parser/token.rb', line 32

def position
  @position
end

#textObject (readonly)

Returns the value of attribute text.



30
31
32
# File 'lib/systemrdl/parser/token.rb', line 30

def text
  @text
end

Instance Method Details

#==(other) ⇒ Object



42
43
44
# File 'lib/systemrdl/parser/token.rb', line 42

def ==(other)
  text == ((other.is_a?(Token) && other.text) || other)
end

#to_symObject



34
35
36
# File 'lib/systemrdl/parser/token.rb', line 34

def to_sym
  text.to_sym
end

#to_token_rangeObject



38
39
40
# File 'lib/systemrdl/parser/token.rb', line 38

def to_token_range
  TokenRange.new(self)
end