ocaml / dune

A composable build system for OCaml.
https://dune.build/
MIT License
1.64k stars 410 forks source link

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

Open MSoegtropIMC opened 4 months ago

MSoegtropIMC commented 4 months ago

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

nojb commented 4 months ago

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.

MSoegtropIMC commented 4 months ago

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.