Parses sequence of statements in braces.
Parses expressions.
Parses expression that can be the argument of a “*”
operator.
Parses literal integers.
Parses names.
Parses programs.
Parses statements.
Parses expression that can be the argument of a “+” or
“-” operator.
Turns a stream of tokens into an abstract syntax tree.
To create a parser, use the companion object’s
forLexer,forFile, orforStringmethods.The parser is the second main component in the language implementation. It reads a stream of tokens from the lexer. It produces an abstract syntax tree which is further processed by the other components (see overview).
The parser has one method
parseNfor each nonterminal symbolNin the grammar´:Additional
parseNmethods are necessary for helper nonterminal symbols to implement operator precedence: