Suppress "never useful" precedence warning in modular parser specifications?
Asked Answered
M

2

5

Is it possible to suppress unused precedence warnings in menhir?

Background:

I have a core parser Lib.mly with several rules and, separately, a host of additional parsers (A.mly, B.mly, ...) which use definitions from Lib.mly. To support using a single lexer for all the languages, all tokens are defined in Lib.mly and we use external_tokens(Lib) annotations in _tags and have extended myocamlbuild.ml to suppress unused tokens warnings with --unused-tokens which helps significantly. However, I still get many warnings of the form:

File "parsers/ParserLib.mly", line 126, characters 0-9:                     
Warning: the precedence level assigned to FIX is never useful.              

These make it hard to see other warnings I actually want to address. Different subsets of the operators are used in various languages, so I need to have a single "global" precedence that orders them appropriately. Thanks for any tips!

Mach answered 17/12, 2017 at 0:30 Comment(0)
T
6

As of today, Menhir has a new option --unused-precedence-levels.

If you have examples of grammars that are split over several files, I might be interested to look at them (and possibly include some of them in Menhir's test suite, if permitted).

Turboprop answered 22/12, 2017 at 15:3 Comment(1)
This works perfectly! Thank you very much for the support and for making menhir such a stellar tool. Our parsers are not yet public, but I will check with my colleagues and send you a tarball.Mach
S
1

Not sure if this is what you're searching for but the two following options may be useful :

--unused-token <token>           Do not warn that <token> is unused
--unused-tokens                  Do not warn about any unused token
Samarskite answered 17/12, 2017 at 11:28 Comment(1)
Yes, those have been helpful for avoiding the unused token warnings. Unfortunately, they don't seem to turn off the "precedence never useful" warnings for said unused tokens :\ I think the next step is filing a menhir issue and just using awk to filter unwanted warnings for now, but ugh.Mach

© 2022 - 2024 — McMap. All rights reserved.