grammar: warn about unused precedence for symbols

Symbols with precedence but no associativity, and whose precedence is
never used, can be declared with %token instead.  The used precedence
relationships are recorded and a warning about useless ones is issued.

* src/conflicts.c (resolve_sr_conflict): Record precedence relation.
* src/symtab.c, src/symtab.h (prec_nodes, init_prec_nodes)
(symgraphlink_new, register_precedence_second_symbol)
(print_precedence_warnings): New.
Record relationships in a graph and warn about useless ones.
* src/main.c (main): Print precedence warnings.
* tests/conflicts.at: New.
This commit is contained in:
Valentin Tolmer
2013-01-29 14:55:53 +01:00
committed by Akim Demaille
parent fbecd2ab59
commit 284bc49c83
6 changed files with 211 additions and 1 deletions

7
NEWS
View File

@@ -198,6 +198,13 @@ GNU Bison NEWS
bar.y: error: shift/reduce conflicts: 1 found, 0 expected
bar.y: error: reduce/reduce conflicts: 2 found, 0 expected
*** Useless precedence
Bison now warns about symbols with a declared precedence but no declared
associativity (i.e. declared with %precedence), and whose precedence is
never used. In that case, the symbol can be safely declared with %token
instead, without modifying the parsing tables.
** Additional yylex/yyparse arguments
The new directive %param declares additional arguments to both yylex and