Parser

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

Constructors

this
this(Token[] tokens)

The constructor takes all tokens so that 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 Compiler iterates through each statement and emits bytecode for it.

Meta