New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using menhir --explain
#6865
Comments
You can disable sandboxing with |
Promoting it doesn't seem right as it seems like a file with error messages/diagnostics. I wonder why menhir doesn't just dump this output into stderr? @fpottier Why is the separate file necessary? |
@Alizter, thank you for the tip: indeed, |
@rgrinberg, indeed, these are diagnostics. Piping them to stdout/stderr would be an option, but what would be the right place with |
This was also the behaviour of "yacc" tools. I think the reason is that this output can be rather large so it is not very useful to read them on the console; one would rather use a text editor. Thinking out loud, what about making this file an explicit output of the Menhir rules? |
Right, but I think we already talked about saving the stderr output of compilation commands to replay warnings. I would imagine this to apply to menhir commands as well. In which case, it would be possible to browse the output with the editor. |
Strangely it does not work in my use case, using dune 3.7.1, either with |
@Lelio-Brun is the command running? Can you check what |
> dune build --sandbox=none --always-show-command-line
File "src/dune", line 7, characters 0-45:
7 | (menhir
8 | (modules parser)
9 | (flags --explain))
(cd _build/.sandbox/9796...938b/default && /home/xxx/_opam/bin/menhir --explain src/parser.mly --base src/parser --infer-read-reply src/parser__mock.mli.inferred) Thanks, so two remarks:
|
It is strange that |
Isn't it just stale artifact deletion? Dune would delete conflicts file because it doesn't know it's a target. |
@rgrinberg But in this case the output of |
Anyway, here is a fix #7607 |
Add the .conflicts file to targets of menhir stanzas when the --explain flag is present and menhir is not called with --only-tokens.
Add the .conflicts file to targets of menhir stanzas when the --explain flag is present and menhir is not called with --only-tokens. Signed-off-by: Kim Nguyễn <kim@nguyen.vg>
Add the .conflicts file to targets of menhir stanzas when the --explain flag is present and menhir is not called with --only-tokens. It also fixes a similar bug where .cmly files where also not kept with sandboxing enabled. Both types of files are also now correctly recognized as targets. Signed-off-by: Kim Nguyễn <kim@nguyen.vg>
I came up here after trying to use Here is my understanding of the situation:
|
Further comments.
|
We essentially already have that in #9025. The issue is that we are trying to support users passing --explain from an
This could be an option. Rather than having case-by-case rules in the menhir implementation, we could simplify it and have menhir produce a directory target for each use case. This would avoid us having to specify each target. I believe menhir rules were added before directory targets were in a usable state, but I don't see any problems having such a feature now. We discussed doing something similar with Coq's extraction feature, which is similar in menhir in the way the rules are written. @emillon Does having menhir rules produce directory targets sound like a viable solution? |
But apparently this makes the implementation more complex, and the end result is that we don't have the feature. I appreciate that you did all this effort, but I would rather have something simple that works. |
Indeed that seems a good idea, barring other more optimal (but also complex) solutions. This is a very important feature, and the |
I gave this one a try: #9512. |
Before
dune.3.0
, with the following stanza,when the menhir grammars have conflicts, the reports that
menhir
generates to describe the conflicts (.conflicts
files, one for each.mli
file) were available in_build/$profile/
.Since
dune.3.0
, sandboxing preventsdune
from keeping these files, forcing the user to runmenhir --explain
manually in the source tree to get the reports.Desired Behavior
The
.conflicts
files could be copied to the_build/$profile/
directory: that would restore the previous behavior (beforedune.3.0
), which was better than the current situation, even if I would prefer never have to touch to the ``_build/` directory.Another behavior could be to promote the
.conflicts
files in the source tree, which would be close to the experience of usingmenhir
withoutdune
, and which would made the.conflicts
file easier to notice. Another possibility could be to dump these files to the standard output when they exist (which can be convenient, but with the same drawbacks than with warnings, that are not displayed again in case of rebuild).Example
A file
test.conflicts
should be available somewhere (or its contents should be displayed) after compiling the following file.test.mly
:dune
:This issue was previously discussed here: https://discuss.ocaml.org/t/how-to-use-menhir-explain-with-dune/11132
The text was updated successfully, but these errors were encountered: