I’m learning how to use Menhir for parsing a language, and so far it’s been great except for error handling. I have a few questions. I’m working with Menhir version 20231231.
First, the manual seems to imply that “new-style” error handling (with the .messages file etc.) only works if the parser is incremental. Is that true? My parser isn’t, because I didn’t want to add any extra complexity I didn’t need. But if the only way to handle errors in a monolithic parser is with the error
token, that should be made clear.
Second, how to use the error
token effectively is not discussed in the manual and as far as I can tell, there are no examples of it in the demos.
Third, even if I just wanted to catch the Error
exception raised by a parse error, I have been unable to do so. The generated parser.mli
file exports the Error
exception, but my parser raises a Parser.MenhirBasics.Error
exception which I can’t catch because the module Parser.MenhirBasics
is not exported.
This is just a huge headache, and I would greatly appreciate any suggestions/advice. Thanks!