Instead of mapping the LHS of unused rules to -1, keep the LHS

valid, but flag the rules as invalid.
* src/gram.h (rule_t): `useful' is a new member.
* src/print.c (print_grammar): Adjust.
* src/derives.c (set_derives): Likewise.
* src/reader.c (packgram, reduce_output): Likewise.
* src/reduce.c (reduce_grammar_tables): Likewise.
* tests/reduce.at (Underivable Rules, Useless Rules): New.
This commit is contained in:
Akim Demaille
2001-11-30 10:46:08 +00:00
parent d287d66a69
commit d39a6b7ca9
7 changed files with 131 additions and 30 deletions

View File

@@ -59,6 +59,8 @@
RULE_TABLE[R].line -- the line where R was defined.
RULE_TABLE[R].useful -- TRUE iff the rule is used.
The right hand side is stored as symbol numbers in a portion of
RITEM.
@@ -119,6 +121,7 @@ typedef struct rule_s
short precsym;
short assoc;
short line;
bool useful;
} rule_t;
extern struct rule_s *rule_table;