How to write parsers fast
I had a fun time writing the openQASM parser over two years ago during my two week visit at UMD College Park. Since then, I have been quite fascinated with parsers. Today, I was trying to write a parser for Lambda Q#, but I wanted to figure out if I could reduce the work I need to do and avoid boilerplate.
I found a few projects that seem helpful:
- Steffen Smolka’s Nice Parser that is meant exactly for this need.
- LĂ©lio Brun’s Obelisk, which I may end up using to generate good documentation for the grammar.
Further, since LambdaQs is based on the Modernized Algol (MA) language of Bob Harper, I somehow also stumbled upon a bunch of projects by Jon Sterling, specifically:
- sml-modernized-algol, which seems like an ABT representation of PFPL. Someone also ended up contributing a parser for the surface syntax later.
- sml-typed-abts, an implementation of Abstract Binding Trees (ABTs). Jon seems to have an OCaml port too, but it seems unmaintained with a single commit.
The latter two projects will be helpful for me to translate Q# source syntax directly into PFPL-style ABTs.
Turns out what I am really looking for is BNF Converter.