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!

ztatlock
  • 190
  • 2
  • 9

2 Answers2

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).

  • 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. – ztatlock Dec 23 '17 at 08:51
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
ghilesZ
  • 1,502
  • 1
  • 18
  • 30
  • 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. – ztatlock Dec 17 '17 at 15:12