mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-10 04:43:03 +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:
@@ -245,6 +245,13 @@ derivation_width (const derivation *deriv)
|
||||
children_width += empty_width;
|
||||
else
|
||||
{
|
||||
if (gl_list_size (deriv->children) == 1
|
||||
&& gl_list_get_first (deriv->children) == &d_dot)
|
||||
{
|
||||
children_width += empty_width;
|
||||
children_width += derivation_separator_width;
|
||||
}
|
||||
|
||||
derivation *child;
|
||||
for (gl_list_iterator_t it = gl_list_iterator (deriv->children);
|
||||
derivation_list_next (&it, &child);
|
||||
@@ -310,6 +317,13 @@ derivation_print_tree_impl (const derivation *deriv, FILE *out,
|
||||
res += fputs_if (depth == 1, out, padding, empty);
|
||||
else
|
||||
{
|
||||
if (gl_list_size (deriv->children) == 1
|
||||
&& gl_list_get_first (deriv->children) == &d_dot)
|
||||
{
|
||||
res += fputs_if (depth == 1, out, padding, empty);
|
||||
res += fputs_if (depth == 1, out, padding, derivation_separator);
|
||||
}
|
||||
|
||||
bool first = true;
|
||||
derivation *child;
|
||||
for (gl_list_iterator_t it = gl_list_iterator (deriv->children);
|
||||
|
||||
Reference in New Issue
Block a user