summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2020-07-11 18:25:49 +0200
committerAkim Demaille <akim.demaille@gmail.com>2020-07-11 18:43:46 +0200
commitee86ea88399ed02243fbceb2704c9ea322a12bf9 (patch)
tree74dbcd687741fd603a210ff98e9b7182233c4e02 /src
parenta2ad33dca63bf3832c07342ce5d5be591a166a8e (diff)
downloadbison-ee86ea88399ed02243fbceb2704c9ea322a12bf9.tar.gz
cex: prefer → to ::=
It does not make a lot of sense to use ::= in our counterexamples, that's not something that belongs to the Bison "vocabulary". Using the colon makes sense, but it's too discreet. Let's use the arrow, which we already use in some reports (HTML and Dot). * src/gram.h (print_dot_fallback): Generalize into... (print_fallback): this. (print_arrow): New. * src/derivation.c: Use it. * NEWS, tests/conflicts.at, tests/counterexample.at, * tests/diagnostics.at, tests/report.at: Adjust. * doc/bison.texi: Ditto. Unfortunately the literal `→` is output as `↦`. So we need to use @arrow.
Diffstat (limited to 'src')
-rw-r--r--src/derivation.c4
-rw-r--r--src/gram.h30
2 files changed, 27 insertions, 7 deletions
diff --git a/src/derivation.c b/src/derivation.c
index 451fabdd..da5649fc 100644
--- a/src/derivation.c
+++ b/src/derivation.c
@@ -145,7 +145,9 @@ derivation_print_impl (const derivation *deriv, FILE *f,
{
fputs (prefix, f);
begin_use_class ("cex-step", f);
- fprintf (f, "%s ::=[ ", sym->tag);
+ fprintf (f, "%s ", sym->tag);
+ print_arrow (f);
+ fprintf (f, " [ ");
end_use_class ("cex-step", f);
prefix = "";
}
diff --git a/src/gram.h b/src/gram.h
index f4f5e55b..6e1da4e8 100644
--- a/src/gram.h
+++ b/src/gram.h
@@ -217,23 +217,41 @@ typedef struct
extern rule *rules;
extern rule_number nrules;
-/* Fallback in case we can't print "•". */
+/* Fallback in case we can't print "•" or "→". */
static inline long
-print_dot_fallback (unsigned int code _GL_UNUSED,
- const char *msg _GL_UNUSED,
- void *callback_arg)
+print_fallback (unsigned int code _GL_UNUSED,
+ const char *msg _GL_UNUSED,
+ void *callback_arg)
{
FILE *out = (FILE *) callback_arg;
- putc ('.', out);
+ switch (code)
+ {
+ case 0x2022:
+ putc ('.', out);
+ break;
+ case 0x2192:
+ fputs ("->", out);
+ break;
+ default:
+ abort ();
+ }
return -1;
}
+/* Print "→", the symbol used to separate the lhs of a rule from its
+ rhs. */
+static inline void
+print_arrow (FILE *out)
+{
+ unicode_to_mb (0x2192, fwrite_success_callback, print_fallback, out);
+}
+
/* Print "•", the symbol used to represent a point in an item (aka, a
dotted rule). */
static inline void
print_dot (FILE *out)
{
- unicode_to_mb (0x2022, fwrite_success_callback, print_dot_fallback, out);
+ unicode_to_mb (0x2022, fwrite_success_callback, print_fallback, out);
}
/* Get the rule associated to this item. ITEM points inside RITEM. */