Package tech.ixor.calclox
Class Parser
java.lang.Object
tech.ixor.calclox.Parser
Builds CalcLox statements and expressions from a token stream.
Expressions are parsed according to CalcLox precedence rules, from assignment through logical, equality, comparison, arithmetic, unary, and call expressions. Loop syntax is lowered to block and while statements before interpretation.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Parser
Creates a parser for a scanner-produced token stream.- Parameters:
tokens- tokens ending inTokenType.EOF- Throws:
NullPointerException- iftokensisnull
-
-
Method Details
-
parse
Parses all declarations and statements up to the EOF token.- Returns:
- statements in execution order
- Throws:
CalcLoxRunnerError- if the token stream does not form a valid program
-