Hi everyone,
I’ve just released LRgrep 0.9, a tool to customize the error messages of Menhir-generated LR parsers by reasoning about failure paths.
The goal is to move from generic “Syntax error at line X” messages to more intuitive diagnostics that point to the actual root cause. For example, if you accidentally put a semicolon in a local-let chain:
let x = 5;
let y = 6
let z = 7
^^^
Error: Expecting 'in' to complete local-let binding.
Hint: this might be due to the semicolon line 1, character 9
Without LRgrep, OCaml typically reports only a syntax error on the subsequent let binding. The customized parser can identify that the semicolon is the likely culprit.
How you can help (feedback wanted!)
I am looking for users to help stress-test the current specifications and identify where error messages are still lacking.
-
If you use OCaml: I’ve patched the compiler to use LRgrep. Please try it via opam:
opam switch create 5.4.1+lrgrep
Please report cases where the error messages are confusing or where you would like to see a more helpful hint. -
If you use Menhir: Give LRgrep a try on your own grammars if you want to customize error messages.
Integration with Merlin is also coming soon (PR #2072).
Huge thanks to @fpottier, @jmid, Tarides, and Jane Street for their support.
Happy testing!