Part of the custom Ab Initio code parser responsible for parsing parsers.
Expressions are used to form statements inside the Parser.
The code below is used to generate a packrat parser for 4 levels of precedence of parsers,
from binding the least to most:
4. |, ||, &&, and, or
3. >=, <=, <, >, !=, ==
2. +, >>, <<
1. *, %, /
To minimize the repetition of the code, there's one main class that defines parsers like if and for, called
Expressions. Each level inherits from this class changing the operators as necessary. E.g. the expression3
changes the operators level from 4 to 3, by overwriting the lazy val declaration.
To ensure that some operators are left recursive (as opposed to right recursive by default), note that those
will contain a match inside binOpExpression's between the current level and the level below.
(Changed in version 2.9.0) The p0 call-by-name arguments is evaluated at most once per constructed Parser object, instead of on every need that arises during parsing.
Part of the custom Ab Initio code parser responsible for parsing parsers.
Expressions are used to form statements inside the Parser.
The code below is used to generate a packrat parser for 4 levels of precedence of parsers, from binding the least to most: 4. |, ||, &&, and, or 3. >=, <=, <, >, !=, == 2. +, >>, << 1. *, %, /
To minimize the repetition of the code, there's one main class that defines parsers like if and for, called Expressions. Each level inherits from this class changing the operators as necessary. E.g. the expression3 changes the operators level from 4 to 3, by overwriting the lazy val declaration.
To ensure that some operators are left recursive (as opposed to right recursive by default), note that those will contain a match inside binOpExpression's between the current level and the level below.