This is a tutorial for how to write a complete parser for a simple calculator using LALRPOP.
If you are unfamiliar with what a parser generator is, you should read Crash course on parsers first.
- Adding LALRPOP to your project
- Parsing parenthesized numbers
- Type inference
- Handling full expressions
- Building ASTs
- Fallible actions
- Error recovery
- Passing state parameter
This tutorial is still incomplete. Here are some topics that I aim to cover when I get time to write about them:
- Advice for resolving shift-reduce and reduce-reduce conflicts
- Passing state and type/lifetime parameters to your action code (see e.g. this test invoked from here).
- Location tracking with
@R(see e.g. this test).
- Integrating with external tokenizers (see e.g. this test invoked from here).
- Conditional macros (no good test to point you at yet, sorry)
- Fallible action code that produces a
Result(see e.g. this test invoked from here).
- Converting to use
LR(1)(see e.g. this test invoked from here).
- Plans for future features