- cmax = 0;
- default_LA = -1;
- fp4 = lookaheadset + tokensetsize;
-
- if (! nodefault)
- for (i = m; i < n; i++)
- {
- fp1 = LA + i * tokensetsize;
- fp2 = shiftset;
- fp3 = lookaheadset;
-
- while (fp3 < fp4)
- *fp3++ = *fp1++ & (~(*fp2++));
-
- count = 0;
- mask = 1;
- fp3 = lookaheadset;
- for (j = 0; j < ntokens; j++)
- {
- if (mask & *fp3)
- count++;
-
- mask <<= 1;
- if (mask == 0)
- {
- mask = 1;
- fp3++;
- }
- }
-
- if (count > cmax)
- {
- cmax = count;
- default_LA = i;
- default_rule = LAruleno[i];
- }
-
- fp2 = shiftset;
- fp3 = lookaheadset;
-
- while (fp3 < fp4)
- *fp2++ |= *fp3++;
- }
-
- for (i = 0; i < tokensetsize; i++)
- shiftset[i] = 0;
-
- if (shiftp)
- {
- k = shiftp->nshifts;
- for (i = 0; i < k; i++)
- {
- if (! shiftp->shifts[i]) continue;
- symbol = accessing_symbol[shiftp->shifts[i]];
- if (ISVAR(symbol)) break;
- SETBIT(shiftset, symbol);
- }
- }
-
- mask = 1;
- fp1 = LA + m * tokensetsize;
- fp2 = shiftset;
- for (i = 0; i < ntokens; i++)
- {
- int defaulted = 0;
-
- if (mask & *fp2)
- count = 1;
- else
- count = 0;
-
- fp3 = fp1;
- for (j = m; j < n; j++)
- {
- if (mask & *fp3)
- {
- if (count == 0)
- {
- if (j != default_LA)
- {
- rule = LAruleno[j];
- fprintf(foutput, " %-4s\treduce using rule %d (%s)\n",
- tags[i], rule, tags[rlhs[rule]]);
- }
- else defaulted = 1;
-
- count++;
- }
- else
- {
- if (defaulted)
- {
- rule = LAruleno[default_LA];
- fprintf(foutput, " %-4s\treduce using rule %d (%s)\n",
- tags[i], rule, tags[rlhs[rule]]);
- defaulted = 0;
- }
- rule = LAruleno[j];
- fprintf(foutput, " %-4s\t[reduce using rule %d (%s)]\n",
- tags[i], rule, tags[rlhs[rule]]);
- }
- }
-
- fp3 += tokensetsize;
- }
-
- mask <<= 1;
- if (mask == 0)
- {
- mask = 1;
- /* We tried incrementing just fp1, and just fp2; both seem wrong.
- It seems necessary to increment both in sync. */
- fp1++;
- fp2++;
- }
- }
-
- if (default_LA >= 0)
- {
- fprintf(foutput, " $default\treduce using rule %d (%s)\n",
- default_rule, tags[rlhs[default_rule]]);
- }