/[bison]/bison/src/conflicts.c
ViewVC logotype

Diff of /bison/src/conflicts.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.81 by akim, Sat Jun 15 18:24:08 2002 UTC revision 1.82 by hilfinger, Fri Jun 28 02:26:43 2002 UTC
# Line 331  count_sr_conflicts (state_t *state) Line 331  count_sr_conflicts (state_t *state)
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;
# Line 353  count_rr_conflicts (state_t *state) Line 356  count_rr_conflicts (state_t *state)
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;
# Line 412  conflicts_output (FILE *out) Line 415  conflicts_output (FILE *out)
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.  |
# Line 442  conflicts_print (void) Line 469  conflicts_print (void)
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);

Legend:
Removed from v.1.81  
changed lines
  Added in v.1.82

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26