ocamlmenhir

menhir `--interpret` for multiple files


I'm trying to use --interpret flag in Menhir to debug my parser, and I have separated my .mly files into tokens and grammar like this:

.
├── dune
├── lexer.mll
├── parser.mly
├── syntax.ml
└── tokens.mly

When using this command:

menhir ./tokens.mly --base ./parser.mly

I got this: Error: no start symbol has been declared.

However, the start symbol is defined in my parser.mly as %start <item> item.

If I then add a --only-tokens flag for tokens.mly like menhir --only-tokens ./tokens.mly --base ./parser.mly, the error will not show up but Menhir will quit immediately.

How should I use Menhir interpret properly for multiple files then?


Solution

  • After seeing this post, I was able to solve the problem:

    menhir tokens.mly --only-tokens
    menhir parser.mly tokens.mly --external-tokens Tokens --base parser --interpret