/[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.22.2.24 by akim, Wed Dec 5 09:20:07 2001 UTC revision 1.22.2.25 by akim, Wed Dec 5 09:20:22 2001 UTC
# Line 255  solve_conflicts (void) Line 255  solve_conflicts (void)
255  static int  static int
256  count_sr_conflicts (int state)  count_sr_conflicts (int state)
257  {  {
258    int i;    int i, k;
   int k;  
   int mask;  
   shifts *shiftp;  
   unsigned *fp1;  
   unsigned *fp2;  
   unsigned *fp3;  
   int symbol;  
   
259    int src_count = 0;    int src_count = 0;
260      shifts *shiftp = state_table[state].shift_table;
261    
   shiftp = state_table[state].shift_table;  
262    if (!shiftp)    if (!shiftp)
263      return 0;      return 0;
264    
# Line 276  count_sr_conflicts (int state) Line 268  count_sr_conflicts (int state)
268        lookaheadset[i] = 0;        lookaheadset[i] = 0;
269      }      }
270    
271    k = shiftp->nshifts;    for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)
   for (i = 0; i < k; i++)  
272      {      {
273        if (!shiftp->shifts[i])        int symbol = state_table[shiftp->shifts[i]].accessing_symbol;
         continue;  
       symbol = state_table[shiftp->shifts[i]].accessing_symbol;  
       if (ISVAR (symbol))  
         break;  
274        SETBIT (shiftset, symbol);        SETBIT (shiftset, symbol);
275      }      }
276    
277    k = state_table[state + 1].lookaheads;    for (i = state_table[state].lookaheads;
278    fp3 = lookaheadset + tokensetsize;         i < state_table[state + 1].lookaheads;
279           ++i)
280    for (i = state_table[state].lookaheads; i < k; i++)      for (k = 0; k < tokensetsize; ++k)
281      {        lookaheadset[k] |= LA (i)[k];
       fp1 = LA (i);  
       fp2 = lookaheadset;  
   
       while (fp2 < fp3)  
         *fp2++ |= *fp1++;  
     }  
282    
283    fp1 = shiftset;    for (k = 0; k < tokensetsize; ++k)
284    fp2 = lookaheadset;      lookaheadset[k] &= shiftset[k];
285    
   while (fp2 < fp3)  
     *fp2++ &= *fp1++;  
   
   mask = 1;  
   fp2 = lookaheadset;  
286    for (i = 0; i < ntokens; i++)    for (i = 0; i < ntokens; i++)
287      {      if (BITISSET (lookaheadset, i))
288        if (mask & *fp2)        src_count++;
         src_count++;  
   
       mask <<= 1;  
       if (mask == 0)  
         {  
           mask = 1;  
           fp2++;  
         }  
     }  
289    
290    return src_count;    return src_count;
291  }  }
# Line 332  static int Line 299  static int
299  count_rr_conflicts (int state)  count_rr_conflicts (int state)
300  {  {
301    int i;    int i;
   unsigned mask;  
   unsigned *baseword;  
   
302    int rrc_count = 0;    int rrc_count = 0;
303    
304    int m = state_table[state].lookaheads;    int m = state_table[state].lookaheads;
# Line 343  count_rr_conflicts (int state) Line 307  count_rr_conflicts (int state)
307    if (n - m < 2)    if (n - m < 2)
308      return 0;      return 0;
309    
   mask = 1;  
   baseword = LA (m);  
310    for (i = 0; i < ntokens; i++)    for (i = 0; i < ntokens; i++)
311      {      {
       unsigned *wordp = baseword;  
   
312        int count = 0;        int count = 0;
313        int j;        int j;
314        for (j = m; j < n; j++)        for (j = m; j < n; j++)
315          {          if (BITISSET (LA (m), j))
316            if (mask & *wordp)            count++;
             count++;  
   
           wordp += tokensetsize;  
         }  
317    
318        if (count >= 2)        if (count >= 2)
319          rrc_count++;          rrc_count++;
   
       mask <<= 1;  
       if (mask == 0)  
         {  
           mask = 1;  
           baseword++;  
         }  
320      }      }
321    
322    return rrc_count;    return rrc_count;
# Line 505  print_reductions (FILE *out, int state) Line 454  print_reductions (FILE *out, int state)
454    int symbol;    int symbol;
455    int m;    int m;
456    int n;    int n;
   int default_LA;  
   int default_rule = 0;  
   int cmax;  
457    shifts *shiftp;    shifts *shiftp;
458    errs *errp;    errs *errp;
459    int nodefault = 0;    int nodefault = 0;
# Line 543  print_reductions (FILE *out, int state) Line 489  print_reductions (FILE *out, int state)
489    if (n - m == 1 && !nodefault)    if (n - m == 1 && !nodefault)
490      {      {
491        int k;        int k;
492        default_rule = LAruleno[m];        int default_rule = LAruleno[m];
493    
494        for (k = 0; k < tokensetsize; ++k)        for (k = 0; k < tokensetsize; ++k)
495          lookaheadset[k] = LA (m)[k] & shiftset[k];          lookaheadset[k] = LA (m)[k] & shiftset[k];
# Line 561  print_reductions (FILE *out, int state) Line 507  print_reductions (FILE *out, int state)
507      {      {
508        int k;        int k;
509    
510        cmax = 0;        int cmax = 0;
511        default_LA = -1;        int default_LA = -1;
512          int default_rule = 0;
513    
514        if (!nodefault)        if (!nodefault)
515          for (i = m; i < n; i++)          for (i = m; i < n; i++)

Legend:
Removed from v.1.22.2.24  
changed lines
  Added in v.1.22.2.25

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