Report rules which are never reduced by the parser: those hidden

by conflicts.
* src/LR0.c (save_reductions): Don't make the final state too
different: save its reduction (accept) instead of having a state
without any action (no shift or goto, no reduce).
Note: the final state is now a ``regular'' state, i.e., the
parsers now contain `reduce 0' as default reduction.
Nevertheless, since they decide to `accept' when yystate =
final_state, they still will not reduce rule 0.
* src/print.c (print_actions, print_reduction): Adjust.
* src/output.c (action_row): Track reduced rules.
(token_actions): Report rules never reduced.
* tests/conflicts.at, tests/regression.at: Adjust.
This commit is contained in:
Akim Demaille
2002-07-30 11:06:50 +00:00
parent caf23d249c
commit e8832397ea
7 changed files with 68 additions and 30 deletions

View File

@@ -286,8 +286,11 @@ print_reduction (FILE *out, size_t width,
fputc (' ', out);
if (!enabled)
fputc ('[', out);
fprintf (out, _("reduce using rule %d (%s)"),
rule->number, rule->lhs->tag);
if (rule->number)
fprintf (out, _("reduce using rule %d (%s)"),
rule->number, rule->lhs->tag);
else
fprintf (out, _("accept"));
if (!enabled)
fputc (']', out);
fputc ('\n', out);
@@ -393,19 +396,6 @@ print_reductions (FILE *out, state_t *state)
static void
print_actions (FILE *out, state_t *state)
{
reductions_t *redp = state->reductions;
transitions_t *transitions = state->transitions;
if (transitions->num == 0 && redp->num == 0)
{
fputc ('\n', out);
if (state->number == final_state->number)
fprintf (out, _(" $default\taccept\n"));
else
fprintf (out, _(" NO ACTIONS\n"));
return;
}
/* Print shifts. */
print_transitions (state, out, TRUE);
print_errs (out, state);