mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-16 07:43:03 +00:00
gram: detect and report (in debug traces) useless chain rules
A rule is a useless chain iff it's a chain (aka unit, or injection) rule (i.e., the RHS has length 1), and it's useless (it has no used defined semantic action). * src/gram.h, src/gram.c (rule_useless_chain_p): New. (grammar_dump): Report useless chain rules. * tests/sets.at: Check the traces.
This commit is contained in:
@@ -232,6 +232,9 @@ bool rule_useless_in_grammar_p (rule const *r);
|
||||
grammar. In other words, it was discarded because of conflicts. */
|
||||
bool rule_useless_in_parser_p (rule const *r);
|
||||
|
||||
/* Whether the rule has a single RHS, and no user action. */
|
||||
bool rule_useless_chain_p (rule const *r);
|
||||
|
||||
/* Print this rule's number and lhs on OUT. If a PREVIOUS_LHS was
|
||||
already displayed (by a previous call for another rule), avoid
|
||||
useless repetitions. */
|
||||
|
||||
Reference in New Issue
Block a user