387 |
} |
} |
388 |
|
|
389 |
|
|
390 |
/*--------------------------------------------------------------. |
/*--------------------------------------------------------. |
391 |
| Return a human readable string which reports shift/reduce and | |
| Report the number of conflicts, using the Yacc format. | |
392 |
| reduce/reduce conflict numbers (SRC_NUM, RRC_NUM). | |
`--------------------------------------------------------*/ |
|
`--------------------------------------------------------------*/ |
|
|
|
|
|
static const char * |
|
|
conflict_report (int src_num, int rrc_num) |
|
|
{ |
|
|
static char res[4096]; |
|
|
char *cp = res; |
|
|
|
|
|
if (src_num >= 1) |
|
|
{ |
|
|
sprintf (cp, ngettext ("%d shift/reduce conflict", |
|
|
"%d shift/reduce conflicts", src_num), src_num); |
|
|
cp += strlen (cp); |
|
|
} |
|
|
|
|
|
if (src_num > 0 && rrc_num > 0) |
|
|
{ |
|
|
sprintf (cp, " %s ", _("and")); |
|
|
cp += strlen (cp); |
|
|
} |
|
|
|
|
|
if (rrc_num >= 1) |
|
|
{ |
|
|
sprintf (cp, ngettext ("%d reduce/reduce conflict", |
|
|
"%d reduce/reduce conflicts", rrc_num), rrc_num); |
|
|
cp += strlen (cp); |
|
|
} |
|
|
|
|
|
*cp++ = '\0'; |
|
|
|
|
|
return res; |
|
|
} |
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------. |
|
|
| Same as above, but report the number of conflicts a` la POSIX. | |
|
|
`----------------------------------------------------------------*/ |
|
393 |
|
|
394 |
static void |
static void |
395 |
conflict_report_yacc (int src_num, int rrc_num) |
conflict_report (FILE *out, int src_num, int rrc_num) |
396 |
{ |
{ |
397 |
/* If invoked with `--yacc', use the output format specified by |
if (src_num && rrc_num) |
398 |
POSIX. */ |
fprintf (out, _("conflicts: %d shift/reduce, %d reduce/reduce\n"), |
399 |
fprintf (stderr, _("conflicts: ")); |
src_num, rrc_num); |
400 |
if (src_num > 0) |
else if (src_num) |
401 |
fprintf (stderr, _(" %d shift/reduce"), src_num); |
fprintf (out, _("conflicts: %d shift/reduce\n"), src_num); |
402 |
if (src_num > 0 && rrc_num > 0) |
else if (rrc_num) |
403 |
fprintf (stderr, ","); |
fprintf (out, _("conflicts: %d reduce/reduce\n"), rrc_num); |
|
if (rrc_num > 0) |
|
|
fprintf (stderr, _(" %d reduce/reduce"), rrc_num); |
|
|
putc ('\n', stderr); |
|
404 |
} |
} |
405 |
|
|
406 |
|
|
418 |
state *s = states[i]; |
state *s = states[i]; |
419 |
if (conflicts[i]) |
if (conflicts[i]) |
420 |
{ |
{ |
421 |
fprintf (out, _("State %d contains "), i); |
fprintf (out, _("State %d "), i); |
422 |
fprintf (out, "%s.\n", |
conflict_report (out, count_sr_conflicts (s), |
423 |
conflict_report (count_sr_conflicts (s), |
count_rr_conflicts (s, true)); |
|
count_rr_conflicts (s, true))); |
|
424 |
printed_sth = true; |
printed_sth = true; |
425 |
} |
} |
426 |
} |
} |
488 |
return; |
return; |
489 |
|
|
490 |
/* Report the total number of conflicts on STDERR. */ |
/* Report the total number of conflicts on STDERR. */ |
491 |
if (yacc_flag) |
if (! yacc_flag) |
492 |
conflict_report_yacc (src_total, rrc_total); |
fprintf (stderr, "%s: ", current_file); |
493 |
else |
conflict_report (stderr, src_total, rrc_total); |
|
warn ("%s", conflict_report (src_total, rrc_total)); |
|
494 |
|
|
495 |
if (expected_conflicts != -1) |
if (expected_conflicts != -1) |
496 |
{ |
{ |