Integrate LRgrep error messages - #2072
Conversation
|
Thanks a lot @let-def ! As you probably noticed we merged the upgrade to 5.5 after you opened this PR. Now we need to rebase it and I would like to use that as an occasion to learn about what it adds to the upgrade process. I will start doing that today ! |
|
Du you think it would be useful to have a ci that diffs lr grep's coverage output ? |
| { "Expected constructor or operator after `(`" } | ||
|
|
||
| | /constr_ident: LPAREN COLONCOLON . RPAREN | ||
| | /mk_longident(mod_ext_longident,__anonymous_42): LPAREN COLONCOLON . RPAREN |
There was a problem hiding this comment.
@let-def What are these __anonymous_42 ? Is it some menhir internal ?
(I am using https://cambium.inria.fr/~fpottier/publis/bour-pottier-lrgrep-2026.pdf to try to decipher this file, but it's not mentioned there)
There was a problem hiding this comment.
It's indeed the names generated by menhir when lambda lifting. Not much I can do about that.
There was a problem hiding this comment.
(at the moment, but it would be nice to cleanup later!)
There was a problem hiding this comment.
How can one know which anonymous is associated to which lambda ? For the upgrade it became invalid and I used the one suggested in the error message.
|
Useful links for review: |
|
After getting rid of many errors when rebased on 5.5 I was finally able to run lrgrep... But is it expected that it takes several minutes to complete ? Some backtrace: And another one a few seconds later: |
|
I stopped it after 20 minutes, something is clearly wrong... |
|
Pinning on lrgrep's main branch fixes the loop ! Still a few fixes to make however 😅 |
|
Unrelated question @let-def, but is there anything that would block this from being merged upstream ? Does it rely on the recovery ? |
This PR integrates LRgrep to generate syntax error messages. This change improves the quality and consistency of error reporting while, hopefully, making the error-handling logic more maintainable. Currently, this is an additive change that complements the existing parser without modifying or removing any existing behavior.
Main changes:
src/ocaml/preprocess/parse_errors.lrgrep, which defines syntax error messages in a clear, declarative format.make lrgrep-coveragetarget generatescoverage.md, a report listing grammatical constructs that currently lack error messages, along with actionable hints for adding coverage.src/ocaml/preprocess/, following the same vendoring pattern used forMenhirLib.The declarative approach should make error messages easier to write, review, and maintain. The coverage tool gives us visibility into error-reporting gaps and guides incremental improvements.
While this PR is a strict addition, the long-term goal is to gradually replace parser components with a version more tightly integrated with LRgrep. This will significantly simplify the preprocessing pipeline and reduce boilerplate in the error recovery and explanation code.