mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +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:
4
TODO
4
TODO
@@ -37,10 +37,6 @@ Unless we play it dumb (little structure).
|
|||||||
|
|
||||||
Use "•" instead of ".".
|
Use "•" instead of ".".
|
||||||
|
|
||||||
*** Conflict coverage
|
|
||||||
Not all the conflicts have counterexamples generated. See the "break"s in
|
|
||||||
counterexample_report_state.
|
|
||||||
|
|
||||||
*** point, dot
|
*** point, dot
|
||||||
We have too many names. In XML we use "point", in C "dot". A traditional
|
We have too many names. In XML we use "point", in C "dot". A traditional
|
||||||
more accurate name of "item" is "pointed rule", so we should probably prefer
|
more accurate name of "item" is "pointed rule", so we should probably prefer
|
||||||
|
|||||||
@@ -1279,21 +1279,17 @@ counterexample_report_state (const state *s, FILE *out, const char *prefix)
|
|||||||
const reductions *reds = s->reductions;
|
const reductions *reds = s->reductions;
|
||||||
for (int i = 0; i < reds->num; ++i)
|
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);
|
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)
|
for (int j = state_item_map[sn]; j < state_item_map[sn + 1]; ++j)
|
||||||
{
|
if (!SI_DISABLED (j))
|
||||||
if (SI_DISABLED (j))
|
{
|
||||||
continue;
|
state_item *si = state_items + j;
|
||||||
state_item *si = state_items + j;
|
item_number conf = *si->item;
|
||||||
item_number conf = *si->item;
|
if (item_number_is_symbol_number (conf)
|
||||||
if (item_number_is_symbol_number (conf)
|
|
||||||
&& bitset_test (reds->lookahead_tokens[i], conf))
|
&& bitset_test (reds->lookahead_tokens[i], conf))
|
||||||
{
|
|
||||||
counterexample_report_shift_reduce (c1, j, conf, out, prefix);
|
counterexample_report_shift_reduce (c1, j, conf, out, prefix);
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int j = i+1; j < reds->num; ++j)
|
for (int j = i+1; j < reds->num; ++j)
|
||||||
{
|
{
|
||||||
bitset conf = bitset_create (ntokens, BITSET_FIXED);
|
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]);
|
reds->lookahead_tokens[j]);
|
||||||
if (!bitset_empty_p (conf))
|
if (!bitset_empty_p (conf))
|
||||||
{
|
{
|
||||||
rule *r2 = reds->rules[j];
|
const rule *r2 = reds->rules[j];
|
||||||
for (int k = state_item_map[sn];
|
for (int k = state_item_map[sn]; k < state_item_map[sn + 1]; ++k)
|
||||||
k < state_item_map[sn + 1]; ++k)
|
if (!SI_DISABLED (k))
|
||||||
{
|
{
|
||||||
if (SI_DISABLED (k))
|
state_item *si = state_items + k;
|
||||||
continue;
|
const rule *r = item_rule (si->item);
|
||||||
state_item *si = state_items + k;
|
if (r == r2)
|
||||||
const rule *r = item_rule (si->item);
|
{
|
||||||
if (r == r2)
|
counterexample_report_reduce_reduce (c1, k, conf, out, prefix);
|
||||||
{
|
break;
|
||||||
counterexample_report_reduce_reduce (c1, k, conf, out, prefix);
|
}
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
bitset_free (conf);
|
bitset_free (conf);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1758,6 +1758,14 @@ State 4
|
|||||||
Second example resolved_conflict . 'a' 'a'
|
Second example resolved_conflict . 'a' 'a'
|
||||||
Second derivation start ::=[ resolved_conflict reported_conflicts ::=[ . 'a' ] 'a' ]
|
Second derivation start ::=[ resolved_conflict reported_conflicts ::=[ . 'a' ] 'a' ]
|
||||||
|
|
||||||
|
Shift/reduce conflict on token 'a':
|
||||||
|
10 reported_conflicts: . %empty
|
||||||
|
9 reported_conflicts: . 'a'
|
||||||
|
First example resolved_conflict . 'a'
|
||||||
|
First derivation start ::=[ resolved_conflict reported_conflicts ::=[ . ] 'a' ]
|
||||||
|
Second example resolved_conflict . 'a' 'a'
|
||||||
|
Second derivation start ::=[ resolved_conflict reported_conflicts ::=[ . 'a' ] 'a' ]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
State 5
|
State 5
|
||||||
|
|||||||
@@ -79,6 +79,11 @@ Shift/reduce conflict on token B:
|
|||||||
First derivation s ::=[ a ::=[ A . ] bc ::=[ B C ] ]
|
First derivation s ::=[ a ::=[ A . ] bc ::=[ B C ] ]
|
||||||
Second derivation s ::=[ ac ::=[ A ac ::=[ b ::=[ . B ] ] C ] ]
|
Second derivation s ::=[ ac ::=[ A ac ::=[ b ::=[ . B ] ] C ] ]
|
||||||
|
|
||||||
|
Shift/reduce conflict on token B:
|
||||||
|
Example A A . B B C C
|
||||||
|
First derivation s ::=[ a ::=[ A a ::=[ A . ] ] bc ::=[ B bc ::=[ B C ] C ] ]
|
||||||
|
Second derivation s ::=[ ac ::=[ A ac ::=[ A ac ::=[ b ::=[ . b ::=[ B B ] ] ] C ] C ] ]
|
||||||
|
|
||||||
input.y:6.4: warning: rule useless in parser due to conflicts [-Wother]
|
input.y:6.4: warning: rule useless in parser due to conflicts [-Wother]
|
||||||
]])
|
]])
|
||||||
|
|
||||||
@@ -328,6 +333,11 @@ Shift/reduce conflict on token B:
|
|||||||
First derivation s ::=[ n ::=[ N a ::=[ A . ] B ] C ]
|
First derivation s ::=[ n ::=[ N a ::=[ A . ] B ] C ]
|
||||||
Second derivation s ::=[ n ::=[ N b ::=[ A . B C ] ] ]
|
Second derivation s ::=[ n ::=[ N b ::=[ A . B C ] ] ]
|
||||||
|
|
||||||
|
Shift/reduce conflict on token B:
|
||||||
|
Example N N A . B D C
|
||||||
|
First derivation s ::=[ n ::=[ N n ::=[ N a ::=[ A . ] B ] D ] C ]
|
||||||
|
Second derivation s ::=[ n ::=[ N n ::=[ N b ::=[ A . B D ] ] C ] ]
|
||||||
|
|
||||||
input.y:5.4: warning: rule useless in parser due to conflicts [-Wother]
|
input.y:5.4: warning: rule useless in parser due to conflicts [-Wother]
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
|||||||
@@ -545,6 +545,12 @@ Shift/reduce conflict on token "else":
|
|||||||
Example <cex-0><cex-leaf>"if"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-leaf>"then"</cex-leaf><cex-1> <cex-leaf>"if"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-leaf>"then"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-dot>•</cex-dot></cex-1> <cex-leaf>"else"</cex-leaf> <cex-leaf>exp</cex-leaf></cex-0>
|
Example <cex-0><cex-leaf>"if"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-leaf>"then"</cex-leaf><cex-1> <cex-leaf>"if"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-leaf>"then"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-dot>•</cex-dot></cex-1> <cex-leaf>"else"</cex-leaf> <cex-leaf>exp</cex-leaf></cex-0>
|
||||||
First derivation <cex-0><cex-step>exp ::=[ </cex-step><cex-leaf>"if"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-leaf>"then"</cex-leaf><cex-1> <cex-step>exp ::=[ </cex-step><cex-leaf>"if"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-leaf>"then"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-dot>•</cex-dot><cex-step> ]</cex-step></cex-1> <cex-leaf>"else"</cex-leaf> <cex-leaf>exp</cex-leaf><cex-step> ]</cex-step></cex-0>
|
First derivation <cex-0><cex-step>exp ::=[ </cex-step><cex-leaf>"if"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-leaf>"then"</cex-leaf><cex-1> <cex-step>exp ::=[ </cex-step><cex-leaf>"if"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-leaf>"then"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-dot>•</cex-dot><cex-step> ]</cex-step></cex-1> <cex-leaf>"else"</cex-leaf> <cex-leaf>exp</cex-leaf><cex-step> ]</cex-step></cex-0>
|
||||||
Example <cex-0><cex-leaf>"if"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-leaf>"then"</cex-leaf><cex-1> <cex-leaf>"if"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-leaf>"then"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-dot>•</cex-dot> <cex-leaf>"else"</cex-leaf> <cex-leaf>exp</cex-leaf></cex-1></cex-0>
|
Example <cex-0><cex-leaf>"if"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-leaf>"then"</cex-leaf><cex-1> <cex-leaf>"if"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-leaf>"then"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-dot>•</cex-dot> <cex-leaf>"else"</cex-leaf> <cex-leaf>exp</cex-leaf></cex-1></cex-0>
|
||||||
|
Second derivation <cex-0><cex-step>exp ::=[ </cex-step><cex-leaf>"if"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-leaf>"then"</cex-leaf><cex-1> <cex-step>exp ::=[ </cex-step><cex-leaf>"if"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-leaf>"then"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-dot>•</cex-dot> <cex-leaf>"else"</cex-leaf> <cex-leaf>exp</cex-leaf><cex-step> ]</cex-step></cex-1><cex-step> ]</cex-step></cex-0>
|
||||||
|
|
||||||
|
Shift/reduce conflict on token "+":
|
||||||
|
Example <cex-0><cex-1><cex-leaf>"if"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-leaf>"then"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-dot>•</cex-dot></cex-1> <cex-leaf>"+"</cex-leaf> <cex-leaf>exp</cex-leaf></cex-0>
|
||||||
|
First derivation <cex-0><cex-step>exp ::=[ </cex-step><cex-1><cex-step>exp ::=[ </cex-step><cex-leaf>"if"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-leaf>"then"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-dot>•</cex-dot><cex-step> ]</cex-step></cex-1> <cex-leaf>"+"</cex-leaf> <cex-leaf>exp</cex-leaf><cex-step> ]</cex-step></cex-0>
|
||||||
|
Example <cex-0><cex-leaf>"if"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-leaf>"then"</cex-leaf><cex-1> <cex-leaf>exp</cex-leaf> <cex-dot>•</cex-dot> <cex-leaf>"+"</cex-leaf> <cex-leaf>exp</cex-leaf></cex-1></cex-0>
|
||||||
Second derivation <cex-0><cex-step>exp ::=[ </cex-step><cex-leaf>"if"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-leaf>"then"</cex-leaf><cex-1> <cex-step>exp ::=[ </cex-step><cex-leaf>exp</cex-leaf> <cex-dot>•</cex-dot> <cex-leaf>"+"</cex-leaf> <cex-leaf>exp</cex-leaf><cex-step> ]</cex-step></cex-1><cex-step> ]</cex-step></cex-0>
|
Second derivation <cex-0><cex-step>exp ::=[ </cex-step><cex-leaf>"if"</cex-leaf> <cex-leaf>exp</cex-leaf> <cex-leaf>"then"</cex-leaf><cex-1> <cex-step>exp ::=[ </cex-step><cex-leaf>exp</cex-leaf> <cex-dot>•</cex-dot> <cex-leaf>"+"</cex-leaf> <cex-leaf>exp</cex-leaf><cex-step> ]</cex-step></cex-1><cex-step> ]</cex-step></cex-0>
|
||||||
|
|
||||||
Shift/reduce conflict on token "+":
|
Shift/reduce conflict on token "+":
|
||||||
|
|||||||
@@ -1190,6 +1190,16 @@ Shift/reduce conflict on token "⊕":
|
|||||||
First derivation exp ::=[ exp ::=[ exp "⊕" exp • ] "⊕" exp ]
|
First derivation exp ::=[ exp ::=[ exp "⊕" exp • ] "⊕" exp ]
|
||||||
Second derivation exp ::=[ exp "⊕" exp ::=[ exp • "⊕" exp ] ]
|
Second derivation exp ::=[ exp "⊕" exp ::=[ exp • "⊕" exp ] ]
|
||||||
|
|
||||||
|
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 "+":
|
||||||
|
Example exp "⊕" exp • "+" exp
|
||||||
|
First derivation exp ::=[ exp ::=[ exp "⊕" exp • ] "+" exp ]
|
||||||
|
Second derivation exp ::=[ exp "⊕" exp ::=[ exp • "+" exp ] ]
|
||||||
|
|
||||||
input.y:6.3-13: warning: rule useless in parser due to conflicts [-Wother]
|
input.y:6.3-13: warning: rule useless in parser due to conflicts [-Wother]
|
||||||
]])
|
]])
|
||||||
|
|
||||||
@@ -1377,6 +1387,20 @@ State 8
|
|||||||
First derivation exp ::=[ exp ::=[ exp "⊕" exp • ] "⊕" exp ]
|
First derivation exp ::=[ exp ::=[ exp "⊕" exp • ] "⊕" exp ]
|
||||||
Second derivation exp ::=[ exp "⊕" exp ::=[ exp • "⊕" exp ] ]
|
Second derivation exp ::=[ exp "⊕" exp ::=[ exp • "⊕" exp ] ]
|
||||||
|
|
||||||
|
Shift/reduce conflict on token "+":
|
||||||
|
1 exp: exp "⊕" exp •
|
||||||
|
2 exp: exp • "+" exp
|
||||||
|
Example exp "⊕" exp • "+" exp
|
||||||
|
First derivation exp ::=[ exp ::=[ exp "⊕" exp • ] "+" exp ]
|
||||||
|
Second derivation exp ::=[ exp "⊕" exp ::=[ exp • "+" exp ] ]
|
||||||
|
|
||||||
|
Shift/reduce conflict on token "+":
|
||||||
|
1 exp: exp "⊕" exp •
|
||||||
|
3 exp: exp • "+" exp
|
||||||
|
Example exp "⊕" exp • "+" exp
|
||||||
|
First derivation exp ::=[ exp ::=[ exp "⊕" exp • ] "+" exp ]
|
||||||
|
Second derivation exp ::=[ exp "⊕" exp ::=[ exp • "+" exp ] ]
|
||||||
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user