]> git.saurik.com Git - bison.git/blobdiff - src/conflicts.c
* src/conflicts.c (print_reductions): Improve variable locality.
[bison.git] / src / conflicts.c
index 82ce14603f5ee7c50ab702f878b15caddf93b5f8..e26a7adf4142a71fd9df5bb11bc48443ba5ce473 100644 (file)
@@ -502,12 +502,6 @@ print_reductions (FILE *out, int state)
 {
   int i;
   int j;
 {
   int i;
   int j;
-  int k;
-  unsigned *fp1;
-  unsigned *fp2;
-  unsigned *fp3;
-  unsigned *fp4;
-  int rule;
   int symbol;
   unsigned mask;
   int m;
   int symbol;
   unsigned mask;
   int m;
@@ -525,33 +519,28 @@ print_reductions (FILE *out, int state)
 
   shiftp = state_table[state].shift_table;
   if (shiftp)
 
   shiftp = state_table[state].shift_table;
   if (shiftp)
-    {
-      k = shiftp->nshifts;
-      for (i = 0; i < k; i++)
-       {
-         if (!shiftp->shifts[i])
-           continue;
-         symbol = state_table[shiftp->shifts[i]].accessing_symbol;
-         if (ISVAR (symbol))
-           break;
-         /* if this state has a shift for the error token,
-            don't use a default rule.  */
-         if (symbol == error_token_number)
-           nodefault = 1;
-         SETBIT (shiftset, symbol);
-       }
-    }
+    for (i = 0; i < shiftp->nshifts; i++)
+      {
+       if (!shiftp->shifts[i])
+         continue;
+       symbol = state_table[shiftp->shifts[i]].accessing_symbol;
+       if (ISVAR (symbol))
+         break;
+       /* if this state has a shift for the error token,
+          don't use a default rule.  */
+       if (symbol == error_token_number)
+         nodefault = 1;
+       SETBIT (shiftset, symbol);
+      }
 
   errp = err_table[state];
   if (errp)
     {
 
   errp = err_table[state];
   if (errp)
     {
-      k = errp->nerrs;
-      for (i = 0; i < k; i++)
+      for (i = 0; i < errp->nerrs; i++)
        {
          if (!errp->errs[i])
            continue;
        {
          if (!errp->errs[i])
            continue;
-         symbol = errp->errs[i];
-         SETBIT (shiftset, symbol);
+         SETBIT (shiftset, errp->errs[i]);
        }
     }
 
        }
     }
 
@@ -560,39 +549,25 @@ print_reductions (FILE *out, int state)
 
   if (n - m == 1 && !nodefault)
     {
 
   if (n - m == 1 && !nodefault)
     {
+      int k;
       default_rule = LAruleno[m];
 
       default_rule = LAruleno[m];
 
-      fp1 = LA (m);
-      fp2 = shiftset;
-      fp3 = lookaheadset;
-      fp4 = lookaheadset + tokensetsize;
-
-      while (fp3 < fp4)
-       *fp3++ = *fp1++ & *fp2++;
-
-      mask = 1;
-      fp3 = lookaheadset;
+      for (k = 0; k < tokensetsize; ++k)
+       lookaheadset[k] = LA (m)[k] & shiftset[k];
 
       for (i = 0; i < ntokens; i++)
 
       for (i = 0; i < ntokens; i++)
-       {
-         if (mask & *fp3)
-           fprintf (out, _("    %-4s\t[reduce using rule %d (%s)]\n"),
-                    tags[i], default_rule,
-                    tags[rule_table[default_rule].lhs]);
-
-         mask <<= 1;
-         if (mask == 0)
-           {
-             mask = 1;
-             fp3++;
-           }
-       }
+       if (BITISSET (lookaheadset, i))
+         fprintf (out, _("    %-4s\t[reduce using rule %d (%s)]\n"),
+                  tags[i], default_rule,
+                  tags[rule_table[default_rule].lhs]);
 
       fprintf (out, _("    $default\treduce using rule %d (%s)\n\n"),
               default_rule, tags[rule_table[default_rule].lhs]);
     }
   else if (n - m >= 1)
     {
 
       fprintf (out, _("    $default\treduce using rule %d (%s)\n\n"),
               default_rule, tags[rule_table[default_rule].lhs]);
     }
   else if (n - m >= 1)
     {
+      unsigned *fp1, *fp2, *fp3, *fp4;
+
       cmax = 0;
       default_LA = -1;
       fp4 = lookaheadset + tokensetsize;
       cmax = 0;
       default_LA = -1;
       fp4 = lookaheadset + tokensetsize;
@@ -642,8 +617,7 @@ print_reductions (FILE *out, int state)
 
       if (shiftp)
        {
 
       if (shiftp)
        {
-         k = shiftp->nshifts;
-         for (i = 0; i < k; i++)
+         for (i = 0; i < shiftp->nshifts; i++)
            {
              if (!shiftp->shifts[i])
                continue;
            {
              if (!shiftp->shifts[i])
                continue;
@@ -674,12 +648,11 @@ print_reductions (FILE *out, int state)
                  if (count == 0)
                    {
                      if (j != default_LA)
                  if (count == 0)
                    {
                      if (j != default_LA)
-                       {
-                         rule = LAruleno[j];
-                         fprintf (out,
-                                  _("    %-4s\treduce using rule %d (%s)\n"),
-                                  tags[i], rule, tags[rule_table[rule].lhs]);
-                       }
+                       fprintf (out,
+                                _("    %-4s\treduce using rule %d (%s)\n"),
+                                tags[i],
+                                LAruleno[j],
+                                tags[rule_table[LAruleno[j]].lhs]);
                      else
                        defaulted = 1;
 
                      else
                        defaulted = 1;
 
@@ -688,17 +661,17 @@ print_reductions (FILE *out, int state)
                  else
                    {
                      if (defaulted)
                  else
                    {
                      if (defaulted)
-                       {
-                         rule = LAruleno[default_LA];
-                         fprintf (out,
-                                  _("    %-4s\treduce using rule %d (%s)\n"),
-                                  tags[i], rule, tags[rule_table[rule].lhs]);
-                         defaulted = 0;
-                       }
-                     rule = LAruleno[j];
+                       fprintf (out,
+                                _("    %-4s\treduce using rule %d (%s)\n"),
+                                tags[i],
+                                LAruleno[default_LA],
+                                tags[rule_table[LAruleno[default_LA]].lhs]);
+                     defaulted = 0;
                      fprintf (out,
                               _("    %-4s\t[reduce using rule %d (%s)]\n"),
                      fprintf (out,
                               _("    %-4s\t[reduce using rule %d (%s)]\n"),
-                              tags[i], rule, tags[rule_table[rule].lhs]);
+                              tags[i],
+                              LAruleno[j],
+                              tags[rule_table[LAruleno[j]].lhs]);
                    }
                }
 
                    }
                }