Package tech.ixor.calclox
Class Scanner
java.lang.Object
tech.ixor.calclox.Scanner
Converts CalcLox source text into the token stream consumed by
Parser.
The scanner recognizes identifiers, reserved words, decimal numbers, strings,
punctuation, and operators. Spaces, tabs, carriage returns, and // line
comments are ignored. Line breaks are retained as token line metadata so later
compilation and runtime errors can identify their source location.
A scanner instance is single-use. Call scanTokens() once for a given source.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Scanner
Creates a scanner positioned at the beginning of the supplied source.- Parameters:
source- complete CalcLox source text- Throws:
NullPointerException- ifsourceisnull
-
-
Method Details
-
scanTokens
Scans the complete source and appends a finalEOFtoken. Number literals are represented asDouble; string literal values omit their surrounding quotation marks.- Returns:
- tokens in source order, including the terminating EOF token
- Throws:
CalcLoxRunnerError- if the source contains an unknown character or an unterminated string
-