Debugging your parser

To debug the parser generated by ocamlyacc:

  • Generate parsing infomation in the file grammar.output using -v option (like “ocamlyacc -v filneme.mly”): the information consists of the parsing table and a report on conflicts.

  • Set p option of the OCAMLRUNPARAM environment variable: for example, execute “export OCAMLRUNPARAM=‘p’ ” on bash shell.

The parser prints messages about its actions such as shifting a token, reducing a rule.

You can find rule numbers and state numbers mentioned in the messages at the file grammar.output.

comments powered by Disqus