Class: Tokn::Token

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

Overview

Tokens read by Tokenizer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, text, lineNumber, column) ⇒ Token

Returns a new instance of Token.



252
253
254
255
256
257
# File 'lib/tokn/tokenizer.rb', line 252

def initialize(id, text, lineNumber, column)
  @id = id
  @text = text
  @lineNumber = lineNumber
  @column = column
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



250
251
252
# File 'lib/tokn/tokenizer.rb', line 250

def column
  @column
end

#idObject (readonly)

Returns the value of attribute id.



250
251
252
# File 'lib/tokn/tokenizer.rb', line 250

def id
  @id
end

#lineNumberObject (readonly)

Returns the value of attribute lineNumber.



250
251
252
# File 'lib/tokn/tokenizer.rb', line 250

def lineNumber
  @lineNumber
end

#textObject (readonly)

Returns the value of attribute text.



250
251
252
# File 'lib/tokn/tokenizer.rb', line 250

def text
  @text
end

Instance Method Details

#inspectObject

Construct description of token location within text



265
266
267
268
269
270
271
# File 'lib/tokn/tokenizer.rb', line 265

def inspect
  s = "(line "+lineNumber.to_s+", col "+column.to_s+")"
  if !unknown?
    s = s.ljust(17) + " : " + text
  end
  s
end

#unknown?Boolean

Returns:

  • (Boolean)


259
260
261
# File 'lib/tokn/tokenizer.rb', line 259

def unknown?
  id == ToknInternal::UNKNOWN_TOKEN
end