mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-14 23:03:04 +00:00
Improve handling of multiple S/R conflicts in the same state and of S/R
conflicts involving multiple reductions. * src/conflicts.c (resolve_sr_conflict): Don't assign the error action set for a state here or Bison will abort if it is reassigned on a later conflicted reduction in the same state. Similarly, don't finalize and assign the solved conflicts report here or it will be lost if it is reassigned on a later conflicted reduction in the same state. (set_conflicts): Instead, assign them both here after all S/R conflicts in the state have been fully examined. * src/print.c (shift_set): Rename to... (no_reduce_set): ... this. (print_reductions): Update for rename, and add %nonassoc error action tokens to no_reduce_set so that, when printing the first remaining reduction on an error action token, the reduction is enclosed in brackets. (print_results): Update for rename. * tests/conflicts.at (Solved conflicts report for multiple reductions in a state): New test case. (%nonassoc error actions for multiple reductions in a state): New test case. * src/main.c (main): Don't depend on C99 features.
This commit is contained in:
17
src/print.c
17
src/print.c
@@ -40,7 +40,7 @@
|
||||
#include "symtab.h"
|
||||
#include "tables.h"
|
||||
|
||||
static bitset shift_set;
|
||||
static bitset no_reduce_set;
|
||||
|
||||
#if 0
|
||||
static void
|
||||
@@ -252,9 +252,12 @@ print_reductions (FILE *out, state *s)
|
||||
if (yydefact[s->number] != 0)
|
||||
default_rule = &rules[yydefact[s->number] - 1];
|
||||
|
||||
bitset_zero (shift_set);
|
||||
bitset_zero (no_reduce_set);
|
||||
FOR_EACH_SHIFT (trans, i)
|
||||
bitset_set (shift_set, TRANSITION_SYMBOL (trans, i));
|
||||
bitset_set (no_reduce_set, TRANSITION_SYMBOL (trans, i));
|
||||
for (i = 0; i < s->errs->num; ++i)
|
||||
if (s->errs->symbols[i])
|
||||
bitset_set (no_reduce_set, s->errs->symbols[i]->number);
|
||||
|
||||
/* Compute the width of the lookahead token column. */
|
||||
if (default_rule)
|
||||
@@ -263,7 +266,7 @@ print_reductions (FILE *out, state *s)
|
||||
if (reds->lookahead_tokens)
|
||||
for (i = 0; i < ntokens; i++)
|
||||
{
|
||||
bool count = bitset_test (shift_set, i);
|
||||
bool count = bitset_test (no_reduce_set, i);
|
||||
|
||||
for (j = 0; j < reds->num; ++j)
|
||||
if (bitset_test (reds->lookahead_tokens[j], i))
|
||||
@@ -293,7 +296,7 @@ print_reductions (FILE *out, state *s)
|
||||
for (i = 0; i < ntokens; i++)
|
||||
{
|
||||
bool defaulted = false;
|
||||
bool count = bitset_test (shift_set, i);
|
||||
bool count = bitset_test (no_reduce_set, i);
|
||||
|
||||
for (j = 0; j < reds->num; ++j)
|
||||
if (bitset_test (reds->lookahead_tokens[j], i))
|
||||
@@ -498,10 +501,10 @@ print_results (void)
|
||||
if (report_flag & report_itemsets)
|
||||
new_closure (nritems);
|
||||
/* Storage for print_reductions. */
|
||||
shift_set = bitset_create (ntokens, BITSET_FIXED);
|
||||
no_reduce_set = bitset_create (ntokens, BITSET_FIXED);
|
||||
for (i = 0; i < nstates; i++)
|
||||
print_state (out, states[i]);
|
||||
bitset_free (shift_set);
|
||||
bitset_free (no_reduce_set);
|
||||
if (report_flag & report_itemsets)
|
||||
free_closure ();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user