Class: LexerToken

Inherits:
Object show all
Defined in:
lib/rpdf2txt-rockit/token.rb

Overview

Forking lexers return LexerToken’s with the info about a matching token and the lexer to access for next tokens.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lexeme, tokenType, lexer, position = nil) ⇒ LexerToken

Returns a new instance of LexerToken.



213
214
215
216
# File 'lib/rpdf2txt-rockit/token.rb', line 213

def initialize(lexeme, tokenType, lexer, position = nil)
  @lexeme, @token_type, @lexer = lexeme, tokenType, lexer
  @position = position
end

Instance Attribute Details

#lexemeObject (readonly)

Returns the value of attribute lexeme.



211
212
213
# File 'lib/rpdf2txt-rockit/token.rb', line 211

def lexeme
  @lexeme
end

#lexerObject (readonly)

Returns the value of attribute lexer.



211
212
213
# File 'lib/rpdf2txt-rockit/token.rb', line 211

def lexer
  @lexer
end

#positionObject (readonly)

Returns the value of attribute position.



211
212
213
# File 'lib/rpdf2txt-rockit/token.rb', line 211

def position
  @position
end

#token_typeObject (readonly)

Returns the value of attribute token_type.



211
212
213
# File 'lib/rpdf2txt-rockit/token.rb', line 211

def token_type
  @token_type
end

Instance Method Details

#create_treeObject



218
219
220
# File 'lib/rpdf2txt-rockit/token.rb', line 218

def create_tree
  @token_type.create_tree(@lexeme, @position)
end

#inspectObject



222
223
224
# File 'lib/rpdf2txt-rockit/token.rb', line 222

def inspect
  "LT(#{lexeme.inspect}, #{token_type.name})"
end