]> git.saurik.com Git - bison.git/blobdiff - src/print.c
* src/vcg.c (quote): Use slot 2, since we often pass symbol tag
[bison.git] / src / print.c
index 280ac8d8417acbe5c4ffe8def58090df8968d31c..8693bbbe739bbd4b11de330a11ec3a80a473a44e 100644 (file)
@@ -93,28 +93,7 @@ print_core (FILE *out, state_t *state)
 
          /* Display the lookaheads?  */
          if (report_flag & report_lookaheads)
-           {
-             int j, k;
-             int nlookaheads = 0;
-             /* Look for lookaheads corresponding to this rule. */
-             for (j = 0; j < state->nlookaheads; ++j)
-               for (k = 0; k < ntokens; ++k)
-                 if (bitset_test (LA[state->lookaheadsp + j], k)
-                     && LArule[state->lookaheadsp + j]->number == rule)
-                   nlookaheads++;
-             if (nlookaheads)
-               {
-                 fprintf (out, "  [");
-                 for (j = 0; j < state->nlookaheads; ++j)
-                   for (k = 0; k < ntokens; ++k)
-                     if (bitset_test (LA[state->lookaheadsp + j], k)
-                         && LArule[state->lookaheadsp + j]->number == rule)
-                       fprintf (out, "%s%s",
-                                symbol_tag_get (symbols[k]),
-                                --nlookaheads ? ", " : "");
-                 fprintf (out, "]");
-               }
-           }
+           state_rule_lookaheads_print (state, &rules[rule], out);
 
          fprintf (out, _("   (rule %d)"), rule - 1);
          fputc ('\n', out);
@@ -134,7 +113,7 @@ print_shifts (FILE *out, state_t *state)
   for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)
     if (!SHIFT_IS_DISABLED (shiftp, i))
       {
-       int state1 = shiftp->shifts[i];
+       state_number_t state1 = shiftp->shifts[i];
        symbol_number_t symbol = states[state1]->accessing_symbol;
        fprintf (out,
                 _("    %-4s\tshift, and go to state %d\n"),
@@ -176,7 +155,7 @@ print_gotos (FILE *out, state_t *state)
       for (; i < shiftp->nshifts; i++)
        if (!SHIFT_IS_DISABLED (shiftp, i))
          {
-           int state1 = shiftp->shifts[i];
+           state_number_t state1 = shiftp->shifts[i];
            symbol_number_t symbol = states[state1]->accessing_symbol;
            fprintf (out, _("    %-4s\tgo to state %d\n"),
                     symbol_tag_get (symbols[symbol]), state1);
@@ -225,9 +204,9 @@ print_reductions (FILE *out, state_t *state)
 
   if (state->nlookaheads == 1 && !nodefault)
     {
-      rule_t *default_rule = LArule[state->lookaheadsp];
+      rule_t *default_rule = state->lookaheads_rule[0];
 
-      bitset_and (lookaheadset, LA[state->lookaheadsp], shiftset);
+      bitset_and (lookaheadset, state->lookaheads[0], shiftset);
 
       for (i = 0; i < ntokens; i++)
        if (bitset_test (lookaheadset, i))
@@ -252,7 +231,7 @@ print_reductions (FILE *out, state_t *state)
            int count = 0;
            int j;
 
-           bitset_andn (lookaheadset, LA[state->lookaheadsp + i], shiftset);
+           bitset_andn (lookaheadset, state->lookaheads[i], shiftset);
 
            for (j = 0; j < ntokens; j++)
              if (bitset_test (lookaheadset, j))
@@ -261,8 +240,8 @@ print_reductions (FILE *out, state_t *state)
            if (count > cmax)
              {
                cmax = count;
-               default_LA = state->lookaheadsp + i;
-               default_rule = LArule[state->lookaheadsp + i];
+               default_LA = i;
+               default_rule = state->lookaheads_rule[i];
              }
 
            bitset_or (shiftset, shiftset, lookaheadset);
@@ -281,16 +260,16 @@ print_reductions (FILE *out, state_t *state)
          int count = bitset_test (shiftset, i);
 
          for (j = 0; j < state->nlookaheads; ++j)
-           if (bitset_test (LA[state->lookaheadsp + j], i))
+           if (bitset_test (state->lookaheads[j], i))
              {
                if (count == 0)
                  {
-                   if (state->lookaheadsp + j != default_LA)
+                   if (j != default_LA)
                      fprintf (out,
                               _("    %-4s\treduce using rule %d (%s)\n"),
                               symbol_tag_get (symbols[i]),
-                              LArule[state->lookaheadsp + j]->number - 1,
-                              symbol_tag_get_n (LArule[state->lookaheadsp + j]->lhs, 1));
+                              state->lookaheads_rule[j]->number - 1,
+                              symbol_tag_get_n (state->lookaheads_rule[j]->lhs, 1));
                    else
                      defaulted = 1;
 
@@ -302,14 +281,14 @@ print_reductions (FILE *out, state_t *state)
                      fprintf (out,
                               _("    %-4s\treduce using rule %d (%s)\n"),
                               symbol_tag_get (symbols[i]),
-                              LArule[default_LA]->number - 1,
-                              symbol_tag_get_n (LArule[default_LA]->lhs, 1));
+                              state->lookaheads_rule[default_LA]->number - 1,
+                              symbol_tag_get_n (state->lookaheads_rule[default_LA]->lhs, 1));
                    defaulted = 0;
                    fprintf (out,
                             _("    %-4s\t[reduce using rule %d (%s)]\n"),
                             symbol_tag_get (symbols[i]),
-                            LArule[state->lookaheadsp + j]->number - 1,
-                            symbol_tag_get_n (LArule[state->lookaheadsp + j]->lhs, 1));
+                            state->lookaheads_rule[j]->number - 1,
+                            symbol_tag_get_n (state->lookaheads_rule[j]->lhs, 1));
                  }
              }
        }
@@ -330,7 +309,7 @@ print_actions (FILE *out, state_t *state)
 
   if (shiftp->nshifts == 0 && redp->nreds == 0)
     {
-      if (final_state == state->number)
+      if (state->number == final_state->number)
        fprintf (out, _("    $default\taccept\n"));
       else
        fprintf (out, _("    NO ACTIONS\n"));
@@ -470,7 +449,7 @@ print_grammar (FILE *out)
 void
 print_results (void)
 {
-  size_t i;
+  state_number_t i;
 
   /* We used to use just .out if SPEC_NAME_PREFIX (-p) was used, but
      that conflicts with Posix.  */