cex: use usual routines for diagnostics about S/R conflicts

See previous commit.  We go from

    input.y: warning: 3 reduce/reduce conflicts [-Wconflicts-rr]
    Shift/reduce conflict on token "⊕":
      Example              exp "+" exp • "⊕" exp
      Shift derivation
        exp
        ↳ exp "+" exp
                  ↳ exp • "⊕" exp

to

    input.y: warning: 3 reduce/reduce conflicts [-Wconflicts-rr]
    input.y: warning: shift/reduce conflict on token "⊕" [-Wcounterexamples]
      Example              exp "+" exp • "⊕" exp
      Shift derivation
        exp
        ↳ exp "+" exp
                  ↳ exp • "⊕" exp

with an hyperlink on -Wcounterexamples.

* src/counterexample.c (counterexample_report_shift_reduce):
Use complain.
* tests/counterexample.at, tests/diagnostics.at, tests/report.at:
Adjust.
This commit is contained in:
Akim Demaille
2020-07-19 19:34:34 +02:00
parent 9922f1f877
commit ea138cd1f1
5 changed files with 60 additions and 53 deletions

View File

@@ -1248,8 +1248,15 @@ counterexample_report_shift_reduce (state_item_number itm1, state_item_number it
symbol_number next_sym,
FILE *out, const char *prefix)
{
fputs (prefix, out);
fprintf (out, _("Shift/reduce conflict on token %s:\n"), symbols[next_sym]->tag);
if (out == stderr)
complain (NULL, Wcounterexamples,
_("shift/reduce conflict on token %s"), symbols[next_sym]->tag);
else
{
fputs (prefix, out);
fprintf (out, _("shift/reduce conflict on token %s"), symbols[next_sym]->tag);
fprintf (out, "%s\n", _(":"));
}
// In the report, print the items.
if (*prefix || trace_flag & trace_cex)
{