Parser

The parser is used by the interpreter to generate a syntax tree out of tokens.

Constructors

this
this(Token[] tokens)

The constructor takes all tokens so that in the future, looking ahead for specific tokens can allow support for lambdas and other complex language features.

Members

Functions

parseExpression
ExpressionNode parseExpression(int minPrec)

parse a single expression. See https://eli.thegreenplace.net/2012/08/02/parsing-expressions-by-precedence-climbing for algorithm.

parseProgram
BlockStatementNode parseProgram()

The main starting point. Also the "program" grammar rule. This method generates a block statement node where the interpreter iterates through each statement and executes it.

Meta