mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-15 07:13:02 +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:
@@ -1776,7 +1776,7 @@ State 4
|
||||
Reduce derivation
|
||||
start
|
||||
`-> 1: resolved_conflict reported_conflicts 'a'
|
||||
`-> 10: .
|
||||
`-> 10: %empty .
|
||||
|
||||
shift/reduce conflict on token 'a':
|
||||
10 reported_conflicts: . %empty
|
||||
@@ -1790,7 +1790,7 @@ State 4
|
||||
Reduce derivation
|
||||
start
|
||||
`-> 1: resolved_conflict reported_conflicts 'a'
|
||||
`-> 10: .
|
||||
`-> 10: %empty .
|
||||
|
||||
|
||||
|
||||
@@ -1999,12 +1999,12 @@ AT_CHECK([[cat input.output | sed -n '/^State 0$/,/^State 1$/p']], 0,
|
||||
Example: . 'c'
|
||||
First reduce derivation
|
||||
start
|
||||
`-> 7: empty_c2 'c'
|
||||
`-> 12: .
|
||||
`-> 7: empty_c2 'c'
|
||||
`-> 12: %empty .
|
||||
Second reduce derivation
|
||||
start
|
||||
`-> 8: empty_c3 'c'
|
||||
`-> 13: .
|
||||
`-> 8: empty_c3 'c'
|
||||
`-> 13: %empty .
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user