* src/gram.h, src/gram.c (rules_rhs_length): New.

(ritem_longest_rhs): Use it.
* src/gram.h (rule_t): `number' is a new member.
* src/reader.c (packgram): Set it.
* src/reduce.c (reduce_grammar_tables): Move the useless rules at
the end of `rules', and count them out of `nrules'.
(reduce_output, dump_grammar): Adjust.
* src/print.c (print_grammar): It is no longer needed to check for
the usefulness of a rule, as useless rules are beyond `nrules + 1'.
* tests/reduce.at (Reduced Automaton): New test.
This commit is contained in:
Akim Demaille
2002-04-07 17:36:38 +00:00
parent c307773eec
commit c3b407f430
17 changed files with 211 additions and 109 deletions

View File

@@ -1687,6 +1687,7 @@ packgram (void)
while (p)
{
bucket *ruleprec = p->ruleprec;
rules[ruleno].number = ruleno;
rules[ruleno].lhs = p->sym->number;
rules[ruleno].rhs = ritem + itemno;
rules[ruleno].line = p->line;