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.
This commit is contained in:
Akim Demaille
2020-07-11 18:25:49 +02:00
parent a2ad33dca6
commit ee86ea8839
8 changed files with 147 additions and 125 deletions

View File

@@ -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 = "";
}

View File

@@ -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. */