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
, orforString
methods.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
parseN
for each nonterminal symbolN
in the grammar´:Additional
parseN
methods are necessary for helper nonterminal symbols to implement operator precedence: