diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2020-07-20 07:03:39 +0200 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2020-07-20 07:09:31 +0200 |
commit | b81229e1f93999c77887422c0795407154876823 (patch) | |
tree | 3a8e04268085cc7801af05c5b8a935068051ecb3 /src | |
parent | 815a76f5583311c6d00024584d153544e9391d5d (diff) | |
download | bison-b81229e1f93999c77887422c0795407154876823.tar.gz |
cex: improve readability of the subsections
Now that the derivation is no longer printed on one line, aligning the
example and the derivation is no longer useful. It can actually be
harmful, as it makes the overall structure less clear.
* src/derivation.h, src/derivation.c (derivation_print_leaves): Remove
the `prefix` argument.
* src/counterexample.c (print_counterexample): Put the example next to
its label.
* tests/conflicts.at, tests/counterexample.at, tests/diagnostics.at,
* tests/report.at: Adjust.
Diffstat (limited to 'src')
-rw-r--r-- | src/counterexample.c | 8 | ||||
-rw-r--r-- | src/derivation.c | 3 | ||||
-rw-r--r-- | src/derivation.h | 2 |
3 files changed, 6 insertions, 7 deletions
diff --git a/src/counterexample.c b/src/counterexample.c index 06ebcd6c..7df75d64 100644 --- a/src/counterexample.c +++ b/src/counterexample.c @@ -116,9 +116,9 @@ static void print_counterexample (const counterexample *cex, FILE *out, const char *prefix) { const bool flat = getenv ("YYFLAT"); - fprintf (out, " %s%-20s ", + fprintf (out, flat ? " %s%-20s " : " %s%s: ", prefix, cex->unifying ? _("Example") : _("First example")); - derivation_print_leaves (cex->d1, out, prefix); + derivation_print_leaves (cex->d1, out); fprintf (out, flat ? " %s%-20s " : " %s%s", prefix, cex->shift_reduce ? _("Shift derivation") : _("First derivation")); derivation_print (cex->d1, out, prefix); @@ -128,9 +128,9 @@ print_counterexample (const counterexample *cex, FILE *out, const char *prefix) // to see the differences. if (!cex->unifying || is_styled (stderr)) { - fprintf (out, " %s%-20s ", + fprintf (out, flat ? " %s%-20s " : " %s%s: ", prefix, cex->unifying ? _("Example") : _("Second example")); - derivation_print_leaves (cex->d2, out, prefix); + derivation_print_leaves (cex->d2, out); } fprintf (out, flat ? " %s%-20s " : " %s%s", prefix, cex->shift_reduce ? _("Reduce derivation") : _("Second derivation")); diff --git a/src/derivation.c b/src/derivation.c index 5ad5a1c8..1e0ff4b7 100644 --- a/src/derivation.c +++ b/src/derivation.c @@ -428,10 +428,9 @@ derivation_print_flat (const derivation *deriv, FILE *out, const char *prefix) } void -derivation_print_leaves (const derivation *deriv, FILE *out, const char *prefix) +derivation_print_leaves (const derivation *deriv, FILE *out) { int counter = 0; - fputs (prefix, out); derivation_print_flat_impl ((derivation *)deriv, out, true, &counter, ""); fputc ('\n', out); } diff --git a/src/derivation.h b/src/derivation.h index 62676368..4dfba945 100644 --- a/src/derivation.h +++ b/src/derivation.h @@ -64,7 +64,7 @@ static inline derivation *derivation_new_leaf (symbol_number sym) // Number of symbols. size_t derivation_size (const derivation *deriv); void derivation_print (const derivation *deriv, FILE *out, const char *prefix); -void derivation_print_leaves (const derivation *deriv, FILE *out, const char *prefix); +void derivation_print_leaves (const derivation *deriv, FILE *out); void derivation_free (derivation *deriv); void derivation_retain (derivation *deriv); |