Class: Token

Token

Represents a scanned lexeme of Lox source code.

Constructor

new Token(type, lexeme, literal, line)

Creates a new token.

Parameters:
Name Type Description
type TokenType

This tokens type. Used by the Parser.

lexeme string

Section of source code this token was parsed from.

literal string | number | undefined

If a token represents a literal, this will be the extracted value; otherwise undefined.

line number

Identifies which line of the source code this token was parsed from.

Source:

Members

lexeme :string

Type:
  • string
Source:

line :number

Type:
  • number
Source:

literal :string|number|undefined

Type:
  • string | number | undefined
Source:

type :TokenType

Type:
Source:

Methods

toString() → {string}

Returns a string representing the token.

Source:
Returns:

A string representing the object.

Type
string