简体   繁体   中英

debugging code with menhir and ocamlbuild

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 dune for a new project and not ocamlbuild ).

Similarly, the --explain flag of menhir is 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 --interpret or list all possible syntax errors in your grammar with menhir --list-errors .

Both options should make the reason why `"hi." is a syntax error relatively clear.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM