439 |
{ |
{ |
440 |
int i; |
int i; |
441 |
|
|
442 |
|
/* Is the number of SR conflicts OK? Either EXPECTED_CONFLICTS is |
443 |
|
not set, and then we want 0 SR, or else it is specified, in which |
444 |
|
case we want equality. */ |
445 |
|
int src_ok = 0; |
446 |
|
|
447 |
int src_total = 0; |
int src_total = 0; |
448 |
int rrc_total = 0; |
int rrc_total = 0; |
449 |
|
|
455 |
rrc_total += count_rr_conflicts (i); |
rrc_total += count_rr_conflicts (i); |
456 |
} |
} |
457 |
|
|
458 |
|
src_ok = src_total == (expected_conflicts == -1 ? 0 : expected_conflicts); |
459 |
|
|
460 |
|
/* If there are no RR conflicts, and as many SR conflicts as |
461 |
|
expected, then there is nothing to report. */ |
462 |
|
if (!rrc_total && src_ok) |
463 |
|
return; |
464 |
|
|
465 |
/* Report the total number of conflicts on STDERR. */ |
/* Report the total number of conflicts on STDERR. */ |
466 |
if (src_total || rrc_total) |
if (yacc_flag) |
467 |
|
{ |
468 |
|
/* If invoked with `--yacc', use the output format specified by |
469 |
|
POSIX. */ |
470 |
|
fprintf (stderr, _("conflicts: ")); |
471 |
|
if (src_total > 0) |
472 |
|
fprintf (stderr, _(" %d shift/reduce"), src_total); |
473 |
|
if (src_total > 0 && rrc_total > 0) |
474 |
|
fprintf (stderr, ","); |
475 |
|
if (rrc_total > 0) |
476 |
|
fprintf (stderr, _(" %d reduce/reduce"), rrc_total); |
477 |
|
putc ('\n', stderr); |
478 |
|
} |
479 |
|
else |
480 |
{ |
{ |
481 |
if (yacc_flag) |
fprintf (stderr, _("%s contains "), infile); |
482 |
{ |
fputs (conflict_report (src_total, rrc_total), stderr); |
|
/* If invoked with `--yacc', use the output format specified by |
|
|
POSIX. */ |
|
|
fprintf (stderr, _("conflicts: ")); |
|
|
if (src_total > 0) |
|
|
fprintf (stderr, _(" %d shift/reduce"), src_total); |
|
|
if (src_total > 0 && rrc_total > 0) |
|
|
fprintf (stderr, ","); |
|
|
if (rrc_total > 0) |
|
|
fprintf (stderr, _(" %d reduce/reduce"), rrc_total); |
|
|
putc ('\n', stderr); |
|
|
} |
|
|
else |
|
|
{ |
|
|
fprintf (stderr, _("%s contains "), infile); |
|
|
fputs (conflict_report (src_total, rrc_total), stderr); |
|
|
} |
|
483 |
} |
} |
484 |
|
|
485 |
if (expected_conflicts != -1 |
if (expected_conflicts != -1 && !src_ok) |
|
&& src_total != expected_conflicts) |
|
486 |
{ |
{ |
487 |
complain_message_count++; |
complain_message_count++; |
488 |
fprintf (stderr, ngettext ("expected %d shift/reduce conflict\n", |
fprintf (stderr, ngettext ("expected %d shift/reduce conflict\n", |