A toy bootstrapped generator of recursive descent parsers.
This is an extraordinarily ancient project (AD 2006), completed as a part of the OO-programming course when I was a first-year student - please keep your expectations low!
YATTA is heavily inspired by ANTLR, the only parser generator I knew at the time. The name comes - of course! - from Green Leaves.
YATTA is a parser generator, which means that it is a program that reads a definition of a context-free grammar and produces a piece of C++ code that is able to parse expressions accordingly. It is bootstrapped, that is, the parser used by YATTA to read grammar definitions has been generated by YATTA itself.
The definition of simple arithmetic expressions is as follows. I think it is sufficiently self-explanatory. The file extension is .yg
for "yatta grammar".
LEXER:
priv digit ('0'..'9');
skip whitespace ('q' | '\t');
token number (digit)(digit)*;
token add ('+' | '-');
token mult ('*' | '/');
token lp ('(');
token rp (')');
PARSER:
rule main (add_expr ENDOFFILE);
rule add_expr (mult_expr)(add mult_expr)*;
rule mult_expr (base_expr)(mult base_expr)*;
rule base_expr (!lp add_expr !rp) | (^number);