331 |
} |
} |
332 |
|
|
333 |
|
|
334 |
/*----------------------------------------------. |
/*----------------------------------------------------------------. |
335 |
| Count the number of reduce/reduce conflicts. | |
| Count the number of reduce/reduce conflicts. If ONE_PER_TOKEN, | |
336 |
`----------------------------------------------*/ |
| count one conflict for each token that has any reduce/reduce | |
337 |
|
| conflicts. Otherwise, count one conflict for each pair of | |
338 |
|
| conflicting reductions. | |
339 |
|
+`----------------------------------------------------------------*/ |
340 |
|
|
341 |
static int |
static int |
342 |
count_rr_conflicts (state_t *state) |
count_rr_conflicts (state_t *state, int one_per_token) |
343 |
{ |
{ |
344 |
int i; |
int i; |
345 |
int rrc_count = 0; |
int rrc_count = 0; |
356 |
count++; |
count++; |
357 |
|
|
358 |
if (count >= 2) |
if (count >= 2) |
359 |
rrc_count++; |
rrc_count += one_per_token ? 1 : count-1; |
360 |
} |
} |
361 |
|
|
362 |
return rrc_count; |
return rrc_count; |
415 |
{ |
{ |
416 |
fprintf (out, _("State %d contains "), i); |
fprintf (out, _("State %d contains "), i); |
417 |
fputs (conflict_report (count_sr_conflicts (states[i]), |
fputs (conflict_report (count_sr_conflicts (states[i]), |
418 |
count_rr_conflicts (states[i])), out); |
count_rr_conflicts (states[i], TRUE)), out); |
419 |
printed_sth = TRUE; |
printed_sth = TRUE; |
420 |
} |
} |
421 |
if (printed_sth) |
if (printed_sth) |
422 |
fputs ("\n\n", out); |
fputs ("\n\n", out); |
423 |
} |
} |
424 |
|
|
425 |
|
/*--------------------------------------------------------. |
426 |
|
| Total the number of S/R and R/R conflicts. Unlike the | |
427 |
|
| code in conflicts_output, however, count EACH pair of | |
428 |
|
| reductions for the same state and lookahead as one | |
429 |
|
| conflict. | |
430 |
|
`--------------------------------------------------------*/ |
431 |
|
|
432 |
|
int |
433 |
|
conflicts_total_count (void) |
434 |
|
{ |
435 |
|
int i; |
436 |
|
int count; |
437 |
|
|
438 |
|
/* Conflicts by state. */ |
439 |
|
count = 0; |
440 |
|
for (i = 0; i < nstates; i++) |
441 |
|
if (conflicts[i]) |
442 |
|
{ |
443 |
|
count += count_sr_conflicts (states[i]); |
444 |
|
count += count_rr_conflicts (states[i], FALSE); |
445 |
|
} |
446 |
|
return count; |
447 |
|
} |
448 |
|
|
449 |
|
|
450 |
/*------------------------------------------. |
/*------------------------------------------. |
451 |
| Reporting the total number of conflicts. | |
| Reporting the total number of conflicts. | |
469 |
if (conflicts[i]) |
if (conflicts[i]) |
470 |
{ |
{ |
471 |
src_total += count_sr_conflicts (states[i]); |
src_total += count_sr_conflicts (states[i]); |
472 |
rrc_total += count_rr_conflicts (states[i]); |
rrc_total += count_rr_conflicts (states[i], TRUE); |
473 |
} |
} |
474 |
|
|
475 |
src_ok = src_total == (expected_conflicts == -1 ? 0 : expected_conflicts); |
src_ok = src_total == (expected_conflicts == -1 ? 0 : expected_conflicts); |