package lrgrep

  1. Overview
  2. Docs
Analyse the stack of a Menhir-generated LR parser using regular expressions

Install

dune-project
 Dependency

Authors

Maintainers

Sources

lrgrep-0.3.tbz
sha256=84a1874d0c063da371e19c84243aac7c40bfcb9aaf204251e0eb0d1f077f2cde
sha512=5a16ff42a196fd741bc64a1bdd45b4dca0098633e73aa665829a44625ec15382891c3643fa210dbe3704336eab095d4024e093e37ae5313810f6754de6119d55

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