package lrgrep

  1. Overview
  2. Docs
Detailed error messages for Menhir-generated parsers

Install

dune-project
 Dependency

Authors

Maintainers

Sources

lrgrep-0.9.tbz
sha256=e53de12e4c5cbe6bca00643593266b4f9fa2e3f6a138195eeff7a4329f5c1c75
sha512=7fd7c4d11506fea7cc11c9bbf5aea9142d905643553c0c90e1bb16b794106b0c14a266acf89ae91b6929008dc0ba6515f788642873e2e4ba6c3d49bd45d25127

doc/README.html

Syntax error analyser

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 .lrgrep 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

Getting started with LRGrep codebase

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