int conflicts_total_count (void) { state_number i; int count; /* Conflicts by state. */ count = 0; for (i = 0; i < nstates; i++) if (conflicts[i]) { count += count_sr_conflicts (states[i]); count += count_rr_conflicts (states[i], false); } return count; }
void conflicts_output (FILE *out) { bool printed_sth = false; state_number i; for (i = 0; i < nstates; i++) { state *s = states[i]; if (conflicts[i]) { fprintf (out, _("State %d "), i); conflict_report (out, count_sr_conflicts (s), count_rr_conflicts (s, true)); printed_sth = true; } } if (printed_sth) fputs ("\n\n", out); }
void conflict_log (void) { register int i; src_total = 0; rrc_total = 0; for (i = 0; i < nstates; i++) { if (conflicts[i]) { count_sr_conflicts(i); count_rr_conflicts(i); src_total += src_count; rrc_total += rrc_count; } } total_conflicts(); }
void verbose_conflict_log (void) { register int i; src_total = 0; rrc_total = 0; for (i = 0; i < nstates; i++) { if (conflicts[i]) { count_sr_conflicts(i); count_rr_conflicts(i); src_total += src_count; rrc_total += rrc_count; fprintf(foutput, _("State %d contains"), i); if (src_count == 1) fprintf(foutput, _(" 1 shift/reduce conflict")); else if (src_count > 1) fprintf(foutput, _(" %d shift/reduce conflicts"), src_count); if (src_count > 0 && rrc_count > 0) fprintf(foutput, _(" and")); if (rrc_count == 1) fprintf(foutput, _(" 1 reduce/reduce conflict")); else if (rrc_count > 1) fprintf(foutput, _(" %d reduce/reduce conflicts"), rrc_count); putc('.', foutput); putc('\n', foutput); } } total_conflicts(); }
void conflicts_print (void) { /* Is the number of SR conflicts OK? Either EXPECTED_CONFLICTS is not set, and then we want 0 SR, or else it is specified, in which case we want equality. */ bool src_ok; bool rrc_ok; int src_total = 0; int rrc_total = 0; int src_expected; int rrc_expected; /* Conflicts by state. */ { state_number i; for (i = 0; i < nstates; i++) if (conflicts[i]) { src_total += count_sr_conflicts (states[i]); rrc_total += count_rr_conflicts (states[i], true); } } if (! glr_parser && rrc_total > 0 && expected_rr_conflicts != -1) { warn (_("%%expect-rr applies only to GLR parsers")); expected_rr_conflicts = -1; } src_expected = expected_sr_conflicts == -1 ? 0 : expected_sr_conflicts; rrc_expected = expected_rr_conflicts == -1 ? 0 : expected_rr_conflicts; src_ok = src_total == src_expected; rrc_ok = rrc_total == rrc_expected; /* If there are as many RR conflicts and SR conflicts as expected, then there is nothing to report. */ if (rrc_ok & src_ok) return; /* Report the total number of conflicts on STDERR. */ if (src_total | rrc_total) { if (! yacc_flag) fprintf (stderr, "%s: ", current_file); conflict_report (stderr, src_total, rrc_total); } if (expected_sr_conflicts != -1 || expected_rr_conflicts != -1) { if (! src_ok) complain (ngettext ("expected %d shift/reduce conflict", "expected %d shift/reduce conflicts", src_expected), src_expected); if (! rrc_ok) complain (ngettext ("expected %d reduce/reduce conflict", "expected %d reduce/reduce conflicts", rrc_expected), rrc_expected); } }