dune icon indicating copy to clipboard operation
dune copied to clipboard

menhir option `--only-tokens` does not work

Open MSoegtropIMC opened this issue 1 year ago • 2 comments

Expected Behavior

This stanza should work and generate tokens.ml/.mli

(menhir
  (modules tokens)
  (flags --only-tokens)
)

Actual Behavior

instead one gets this error:

12 | (menhir
13 |   (modules tokens)
14 |   (flags --only-tokens)
15 | )
Error: Rule failed to generate the following targets:
- plantuml/tokens.conflicts

This works fine with (using menhir 2.0) but not with (using menhir 3.0), so this is a regression.

The issue is likely that in 3.0 the --explain option is default, but with --only-tokens no .conflict file is created by menhir.

Reproduction

See above

Specifications

  • Version of dune (output of dune --version): 3.15.3
  • Version of ocaml (output of ocamlc --version): 4.14.2
  • Operating system (distribution and version): MacOS
  • menhir version: 20230608

MSoegtropIMC avatar Jul 16 '24 16:07 MSoegtropIMC

The issue is likely that in 3.0 the --explain option is default, but with --only-tokens no .conflict file is created by menhir.

Well spotted. In the meantime you can untoggle --explain by passing (explain false) to the Menhir stanza.

nojb avatar Jul 16 '24 16:07 nojb

Thanks, this works!

It is btw. not entirely trivial to get the correct set of stanzas in the external tokens case. In case the token definitions are not repeated in the parser file, the correct set of stanzas is:

(menhir
  (modules tokens)
  (explain false)
  (flags --only-tokens)
)

(menhir
  (modules parser tokens)
  (merge_into parser)
  (flags --external-tokens Tokens)
)

It might make sense to mention this in the dune manual.

MSoegtropIMC avatar Jul 16 '24 16:07 MSoegtropIMC