This repository provides different tools to work on the error messages of a menhir-generated parser.
The main tool is lrgrep
. It takes:
- a compiled Menhir grammar (a .cmly file, produced by passing
--cmly
flag to Menhir) - a list of rules (usually a .mlyl file).
If the list of rule is well-formed, it produces an OCaml module that can match the rules against the state of a parser at runtime.
By carefully crafting the rules, one can provide fine-grained message to explain syntax errors.
The repository is is structured as follow:
- the main tool, lrgrep, can be found in src/main.ml
- support implements the compact table representation shared by the
generator and the generated analysers via the
lrgrep.runtime
library - lib implements various algorithms used by other tools
I am trying to document the code. Each of the src, lib, and support directories contain a README.md that briefly explains the purpose of this directory.
External dependencies that are worth knowing:
- MenhirSdk is a part of the Menhir parser generator that allows external tool to post-process compiled grammars
- Cmon is a pretty-printer for recursive values
- Fix is a library for computing fixed points; it also provides a convenient representation of finite sets
- LRijkstra is taken from Menhir and implements the algorithm described in "Faster Reachability Analysis for LR(1) Parsers", though we apply it for a slightly different purpose than the one described in the articles