This is an example packrat parser combinator for a small DSL that parses these two functions:
def foo(a: Int, b: Int, c: Int) : Int = {
let d = a + b * c;
let e = a + b + d;
return e;
}
and
def bar(a: Int, b: Int, c: Int) : Int = {
let d = a > b and c > a + b;
return d;
}
It shows
- Example of full lexer and parser using packrat parsers
- Writing lexer using RegexParsers
- Parsing that correctly handles
- operator precedence (4 example levels)
- operator associativity
- generating abstract syntax tree (AST)
- Debugging support for parsing rules
./gradlew run