mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 00:33:03 +00:00
* 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:
24
src/print.c
24
src/print.c
@@ -366,19 +366,17 @@ print_grammar (FILE *out)
|
||||
fprintf (out, "%s\n\n", _("Grammar"));
|
||||
fprintf (out, " %s\n", _("Number, Line, Rule"));
|
||||
for (i = 1; i < nrules + 1; i++)
|
||||
/* Don't print rules disabled in reduce_grammar_tables. */
|
||||
if (rules[i].useful)
|
||||
{
|
||||
fprintf (out, _(" %3d %3d %s ->"),
|
||||
i - 1, rules[i].line, escape (symbols[rules[i].lhs]->tag));
|
||||
rule = rules[i].rhs;
|
||||
if (*rule >= 0)
|
||||
while (*rule >= 0)
|
||||
fprintf (out, " %s", escape (symbols[*rule++]->tag));
|
||||
else
|
||||
fprintf (out, " /* %s */", _("empty"));
|
||||
fputc ('\n', out);
|
||||
}
|
||||
{
|
||||
fprintf (out, _(" %3d %3d %s ->"),
|
||||
i - 1, rules[i].line, escape (symbols[rules[i].lhs]->tag));
|
||||
rule = rules[i].rhs;
|
||||
if (*rule >= 0)
|
||||
while (*rule >= 0)
|
||||
fprintf (out, " %s", escape (symbols[*rule++]->tag));
|
||||
else
|
||||
fprintf (out, " /* %s */", _("empty"));
|
||||
fputc ('\n', out);
|
||||
}
|
||||
fputs ("\n\n", out);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user