mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-14 23:03:04 +00:00
cex: always show ε/%empty in counterexamples
On a case such as
%%
exp
: empty "a"
| "a" empty
empty
: %empty
we used to display
warning: shift/reduce conflict on token "a" [-Wcounterexamples]
Example: • "a"
Shift derivation
exp
↳ 2: • "a" empty
↳ 2: ε
Example: • "a"
Reduce derivation
exp
↳ 1: empty "a"
↳ 3: •
where the shift derivation shows an item "2: empty → ε", with an
explicit "ε", but the reduce derivation shows "3: empty → •", without
"ε".
For consistency, let's always show ε/%empty in rules with an empty
rhs:
Reduce derivation
exp
↳ 1: empty "a"
↳ 3: ε •
* src/derivation.c (derivation_width, derivation_print_tree_impl):
Always show ε/%empty in counterexamples.
* tests/diagnostics.at: Check that case.
* tests/conflicts.at, tests/counterexample.at: Adjust.
This commit is contained in:
@@ -532,9 +532,58 @@ exp
|
||||
exp
|
||||
: "if" exp "then" exp
|
||||
| "if" exp "then" exp "else" exp
|
||||
| exp "+" exp
|
||||
| "num"
|
||||
| empty "a"
|
||||
| "a" empty
|
||||
|
||||
empty
|
||||
: %empty
|
||||
]],
|
||||
]],
|
||||
[1],
|
||||
[[input.y: <error>error:</error> shift/reduce conflicts: 9 found, 0 expected
|
||||
input.y: <warning>warning:</warning> shift/reduce conflict on token "a" [<warning>-Wcounterexamples</warning>]
|
||||
Example: <cex-0><cex-dot>•</cex-dot> <cex-leaf>"a"</cex-leaf><cex-1></cex-1></cex-0>
|
||||
Shift derivation
|
||||
<cex-0><cex-step>exp</cex-step></cex-0>
|
||||
<cex-0><cex-step>↳ 6: <cex-dot>•</cex-dot><cex-leaf> "a"</cex-leaf><cex-1><cex-step> empty</cex-step></cex-1></cex-step></cex-0>
|
||||
<cex-1><cex-step> ↳ 6: ε</cex-step></cex-1>
|
||||
Example: <cex-0><cex-1><cex-dot>•</cex-dot></cex-1> <cex-leaf>"a"</cex-leaf></cex-0>
|
||||
Reduce derivation
|
||||
<cex-0><cex-step>exp</cex-step></cex-0>
|
||||
<cex-0><cex-step>↳ 5: <cex-1><cex-step>empty</cex-step></cex-1><cex-leaf> "a"</cex-leaf></cex-step></cex-0>
|
||||
<cex-1><cex-step> ↳ 7: ε<cex-dot> •</cex-dot></cex-step></cex-1>
|
||||
input.y: <warning>warning:</warning> shift/reduce conflict on token "a" [<warning>-Wcounterexamples</warning>]
|
||||
Example: <cex-0><cex-dot>•</cex-dot> <cex-leaf>"a"</cex-leaf><cex-1></cex-1></cex-0>
|
||||
Shift derivation
|
||||
<cex-0><cex-step>exp</cex-step></cex-0>
|
||||
<cex-0><cex-step>↳ 6: <cex-dot>•</cex-dot><cex-leaf> "a"</cex-leaf><cex-1><cex-step> empty</cex-step></cex-1></cex-step></cex-0>
|
||||
<cex-1><cex-step> ↳ 6: ε</cex-step></cex-1>
|
||||
Example: <cex-0><cex-1><cex-dot>•</cex-dot></cex-1> <cex-leaf>"a"</cex-leaf></cex-0>
|
||||
Reduce derivation
|
||||
<cex-0><cex-step>exp</cex-step></cex-0>
|
||||
<cex-0><cex-step>↳ 5: <cex-1><cex-step>empty</cex-step></cex-1><cex-leaf> "a"</cex-leaf></cex-step></cex-0>
|
||||
<cex-1><cex-step> ↳ 7: ε<cex-dot> •</cex-dot></cex-step></cex-1>
|
||||
input.y: <warning>warning:</warning> shift/reduce conflict on token "a" [<warning>-Wcounterexamples</warning>]
|
||||
Example: <cex-0><cex-dot>•</cex-dot> <cex-leaf>"a"</cex-leaf><cex-1></cex-1></cex-0>
|
||||
Shift derivation
|
||||
<cex-0><cex-step>exp</cex-step></cex-0>
|
||||
<cex-0><cex-step>↳ 6: <cex-dot>•</cex-dot><cex-leaf> "a"</cex-leaf><cex-1><cex-step> empty</cex-step></cex-1></cex-step></cex-0>
|
||||
<cex-1><cex-step> ↳ 6: ε</cex-step></cex-1>
|
||||
Example: <cex-0><cex-1><cex-dot>•</cex-dot></cex-1> <cex-leaf>"a"</cex-leaf></cex-0>
|
||||
Reduce derivation
|
||||
<cex-0><cex-step>exp</cex-step></cex-0>
|
||||
<cex-0><cex-step>↳ 5: <cex-1><cex-step>empty</cex-step></cex-1><cex-leaf> "a"</cex-leaf></cex-step></cex-0>
|
||||
<cex-1><cex-step> ↳ 7: ε<cex-dot> •</cex-dot></cex-step></cex-1>
|
||||
input.y: <warning>warning:</warning> shift/reduce conflict on token "a" [<warning>-Wcounterexamples</warning>]
|
||||
Example: <cex-0><cex-dot>•</cex-dot> <cex-leaf>"a"</cex-leaf><cex-1></cex-1></cex-0>
|
||||
Shift derivation
|
||||
<cex-0><cex-step>exp</cex-step></cex-0>
|
||||
<cex-0><cex-step>↳ 6: <cex-dot>•</cex-dot><cex-leaf> "a"</cex-leaf><cex-1><cex-step> empty</cex-step></cex-1></cex-step></cex-0>
|
||||
<cex-1><cex-step> ↳ 6: ε</cex-step></cex-1>
|
||||
Example: <cex-0><cex-1><cex-dot>•</cex-dot></cex-1> <cex-leaf>"a"</cex-leaf></cex-0>
|
||||
Reduce derivation
|
||||
<cex-0><cex-step>exp</cex-step></cex-0>
|
||||
<cex-0><cex-step>↳ 5: <cex-1><cex-step>empty</cex-step></cex-1><cex-leaf> "a"</cex-leaf></cex-step></cex-0>
|
||||
<cex-1><cex-step> ↳ 7: ε<cex-dot> •</cex-dot></cex-step></cex-1>
|
||||
input.y: <warning>warning:</warning> shift/reduce conflict on token "+" [<warning>-Wcounterexamples</warning>]
|
||||
@@ -568,6 +617,17 @@ input.y: <warning>warning:</warning> shift/reduce conflict on token "+" [<warnin
|
||||
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>
|
||||
Reduce derivation
|
||||
<cex-0><cex-step>exp</cex-step></cex-0>
|
||||
<cex-0><cex-step>↳ 3: <cex-1><cex-step>exp</cex-step></cex-1><cex-leaf> "+"</cex-leaf><cex-leaf> exp</cex-leaf></cex-step></cex-0>
|
||||
<cex-1><cex-step> ↳ 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-step></cex-1>
|
||||
input.y: <warning>warning:</warning> shift/reduce conflict on token "a" [<warning>-Wcounterexamples</warning>]
|
||||
Example: <cex-0><cex-dot>•</cex-dot> <cex-leaf>"a"</cex-leaf><cex-1></cex-1></cex-0>
|
||||
Shift derivation
|
||||
<cex-0><cex-step>exp</cex-step></cex-0>
|
||||
<cex-0><cex-step>↳ 6: <cex-dot>•</cex-dot><cex-leaf> "a"</cex-leaf><cex-1><cex-step> empty</cex-step></cex-1></cex-step></cex-0>
|
||||
<cex-1><cex-step> ↳ 6: ε</cex-step></cex-1>
|
||||
Example: <cex-0><cex-1><cex-dot>•</cex-dot></cex-1> <cex-leaf>"a"</cex-leaf></cex-0>
|
||||
Reduce derivation
|
||||
<cex-0><cex-step>exp</cex-step></cex-0>
|
||||
<cex-0><cex-step>↳ 5: <cex-1><cex-step>empty</cex-step></cex-1><cex-leaf> "a"</cex-leaf></cex-step></cex-0>
|
||||
<cex-1><cex-step> ↳ 7: ε<cex-dot> •</cex-dot></cex-step></cex-1>
|
||||
input.y: <warning>warning:</warning> shift/reduce conflict on token "+" [<warning>-Wcounterexamples</warning>]
|
||||
|
||||
Reference in New Issue
Block a user