JavaScript is disabled on your browser.
public class Token
extends Object
One lexical unit of CalcLox source.
Tokens retain the original lexeme and one-based line number. Literal tokens also
carry their decoded runtime value: a Double for numbers, a String
for strings, and null for tokens without a literal value.
Field Summary
Fields
Exact source text occupied by this token.
final int
One-based source line on which the token ends.
Parsed literal value, or null when the token has none.
Syntactic category recognized by the scanner.
Constructor Summary
Constructors
Method Summary
All Methods Instance Methods Concrete Methods
Formats the token as its type, lexeme, and literal value for diagnostics.
Field Details
type
Syntactic category recognized by the scanner.
lexeme
Exact source text occupied by this token.
literal
Parsed literal value, or null when the token has none.
line
public final int line
One-based source line on which the token ends.
Constructor Details
Token
Creates a token.
Parameters:
type - syntactic category
lexeme - original source text
literal - parsed literal value
line - one-based source line
Method Details
toString
Formats the token as its type, lexeme, and literal value for diagnostics.
Overrides:
toString in class Object
Returns:
diagnostic token representation