I am implementing a small programming language. Here is the codebase. The program is built with ocamlbuild. I added a parser using menhir. When I compile and run the program, I got the following message.
❱ ./main.byte
Fatal error: exception Parser.MenhirBasics.Error
I am trying to find more details by passing the explain to the _tag file
true: color(always), explain
but there doesn't seem to be any difference. How to I make menhir to generate a logging file through ocamlbuild? or other ways to debug?
This is syntax error raised by the parser generated by menhir.
Your build system is irrelevant (nevertheless, you should use
dunefor a new project and notocamlbuild).Similarly, the
--explainflag ofmenhiris only useful for generating conflict explanations when generating the parser. It doesn't add syntax error explanation to syntax error.If you want to debug a menhir grammar, you can use menhir intepreter mode with
menhir --interpretor list all possible syntax errors in your grammar with
menhir --list-errors.Both options should make the reason why `"hi." is a syntax error in your grammar relatively clear.