mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-10 21:03:04 +00:00
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:
committed by
Akim Demaille
parent
fbecd2ab59
commit
284bc49c83
@@ -276,11 +276,13 @@ resolve_sr_conflict (state *s, int ruleno, symbol **errors, int *nerrs)
|
||||
The precedence of shifting is that of token i. */
|
||||
if (symbols[i]->prec < redprec)
|
||||
{
|
||||
register_precedence (redrule->prec->number, i);
|
||||
log_resolution (redrule, i, reduce_resolution);
|
||||
flush_shift (s, i);
|
||||
}
|
||||
else if (symbols[i]->prec > redprec)
|
||||
{
|
||||
register_precedence (i, redrule->prec->number);
|
||||
log_resolution (redrule, i, shift_resolution);
|
||||
flush_reduce (lookahead_tokens, i);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user