Human Readable Parser Generator
TLDR;
- Human readable lexer parsers
- Easily add language backends
- (Almost) ANTLR4 compatible grammars
Writing a lexer/parser by hand, while not that difficult, can be extremely tedious. After the honeymoon period of the new language has worn off, it can feel like downright drudgery at times. Instead, I propose a parser generator that generates human-readable lexers and parsers that look like they might have been written by a human. This also allows the freedom to use the parser generator as just a starting point and then take over by hand later.
A second goal is to support a wide number of language backends easily. To do this, we generate the lexer/parser into a language agnostic AST. We then pass this AST into a base class that is designed to process this AST for typical imperative style languages by only needing to define basic characteristics of the language. More exotic languages can be generated, but they will take more customization work.
A third goal is to use a parser grammar format that is very similar to ANTLR4 to take advantage of the many available grammars. The expected format is likely to be a bit more limited than ANTLR's, so some minor customization is likely due to generated parser differences (precedence handling, etc.) and a slimmer feature set.
NOTE: Subject to change
- Lex/Parse Grammar --> Grammar AST
- Process/Optimize Grammar (and check for errors) --> New Grammar AST
- Generate Lexer/Parser --> Language Agnostic AST
- Walk Language Agnostic AST --> Lexer/Parser Language Files
In development - it is not ready for use in any way
The resulting executable file can be found at target/release/hrpg
.
cargo build --release