mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
cex: display all the S/R conflicts, not just one per (state, rule)
Before this commit, on
%%
exp
: "if" exp "then" exp
| "if" exp "then" exp "else" exp
| exp "+" exp
| "num"
we used to not display the third counterexample below:
Shift/reduce conflict on token "+":
Example exp "+" exp . "+" exp
First derivation exp ::=[ exp ::=[ exp "+" exp . ] "+" exp ]
Second derivation exp ::=[ exp "+" exp ::=[ exp . "+" exp ] ]
Shift/reduce conflict on token "else":
Example "if" exp "then" "if" exp "then" exp . "else" exp
First derivation exp ::=[ "if" exp "then" exp ::=[ "if" exp "then" exp . ] "else" exp ]
Second derivation exp ::=[ "if" exp "then" exp ::=[ "if" exp "then" exp . "else" exp ] ]
Shift/reduce conflict on token "+":
Example "if" exp "then" exp . "+" exp
First derivation exp ::=[ exp ::=[ "if" exp "then" exp . ] "+" exp ]
Second derivation exp ::=[ "if" exp "then" exp ::=[ exp . "+" exp ] ]
Shift/reduce conflict on token "+":
Example "if" exp "then" exp "else" exp . "+" exp
First derivation exp ::=[ exp ::=[ "if" exp "then" exp "else" exp . ] "+" exp ]
Second derivation exp ::=[ "if" exp "then" exp "else" exp ::=[ exp . "+" exp ] ]
* src/counterexample.c (counterexample_report_state): Don't stop of
the first conflicts.
* tests/conflicts.at, tests/counterexample.at, tests/diagnostics.at,
* tests/report.at: Adjust.
This commit is contained in:
@@ -1279,21 +1279,17 @@ counterexample_report_state (const state *s, FILE *out, const char *prefix)
|
||||
const reductions *reds = s->reductions;
|
||||
for (int i = 0; i < reds->num; ++i)
|
||||
{
|
||||
rule *r1 = reds->rules[i];
|
||||
const rule *r1 = reds->rules[i];
|
||||
const state_item_number c1 = find_state_item_number (r1, sn);
|
||||
for (int j = state_item_map[sn]; j < state_item_map[sn + 1]; ++j)
|
||||
{
|
||||
if (SI_DISABLED (j))
|
||||
continue;
|
||||
state_item *si = state_items + j;
|
||||
item_number conf = *si->item;
|
||||
if (item_number_is_symbol_number (conf)
|
||||
if (!SI_DISABLED (j))
|
||||
{
|
||||
state_item *si = state_items + j;
|
||||
item_number conf = *si->item;
|
||||
if (item_number_is_symbol_number (conf)
|
||||
&& bitset_test (reds->lookahead_tokens[i], conf))
|
||||
{
|
||||
counterexample_report_shift_reduce (c1, j, conf, out, prefix);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int j = i+1; j < reds->num; ++j)
|
||||
{
|
||||
bitset conf = bitset_create (ntokens, BITSET_FIXED);
|
||||
@@ -1302,20 +1298,18 @@ counterexample_report_state (const state *s, FILE *out, const char *prefix)
|
||||
reds->lookahead_tokens[j]);
|
||||
if (!bitset_empty_p (conf))
|
||||
{
|
||||
rule *r2 = reds->rules[j];
|
||||
for (int k = state_item_map[sn];
|
||||
k < state_item_map[sn + 1]; ++k)
|
||||
{
|
||||
if (SI_DISABLED (k))
|
||||
continue;
|
||||
state_item *si = state_items + k;
|
||||
const rule *r = item_rule (si->item);
|
||||
if (r == r2)
|
||||
{
|
||||
counterexample_report_reduce_reduce (c1, k, conf, out, prefix);
|
||||
break;
|
||||
}
|
||||
}
|
||||
const rule *r2 = reds->rules[j];
|
||||
for (int k = state_item_map[sn]; k < state_item_map[sn + 1]; ++k)
|
||||
if (!SI_DISABLED (k))
|
||||
{
|
||||
state_item *si = state_items + k;
|
||||
const rule *r = item_rule (si->item);
|
||||
if (r == r2)
|
||||
{
|
||||
counterexample_report_reduce_reduce (c1, k, conf, out, prefix);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
bitset_free (conf);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user