]> git.saurik.com Git - bison.git/blobdiff - src/output.c
* src/gram.h (item_number_t): New, the type of item numbers in
[bison.git] / src / output.c
index a098cb63f46ab97c036fd20fffd323be2b606631..df751cb02b9393ec7edc5101b8d5f6ad9580c680 100644 (file)
@@ -147,15 +147,19 @@ get_lines_number (const char *s)
 }
 
 
-/* FIXME. */
+/*----------------------------------------------------------------.
+| Format the FIRST and then TABLE_DATA[BEGIN..END[ into OOUT, and |
+| return the number of bits needed for its longuest value.        |
+`----------------------------------------------------------------*/
 
-static inline void
+static inline long int
 output_table_data (struct obstack *oout,
                   short *table_data,
                   short first,
                   int begin,
                   int end)
 {
+  long int max = first;
   int i;
   int j = 1;
 
@@ -171,8 +175,12 @@ output_table_data (struct obstack *oout,
       else
        ++j;
       obstack_fgrow1 (oout, "%6d", table_data[i]);
+      if (table_data[i] > max)
+       max = table_data[i];
     }
   obstack_1grow (oout, 0);
+
+  return max;
 }
 
 
@@ -184,9 +192,10 @@ output_table_data (struct obstack *oout,
 static void
 prepare_tokens (void)
 {
-  output_table_data (&format_obstack, token_translations,
-                    0, 1, max_user_token_number + 1);
+  long int max = output_table_data (&format_obstack, token_translations,
+                                   0, 1, max_user_token_number + 1);
   muscle_insert ("translate", obstack_finish (&format_obstack));
+  MUSCLE_INSERT_LONG_INT ("token_number_max", max);
   XFREE (token_translations);
 
   {
@@ -348,7 +357,7 @@ action_row (state_t *state)
          /* and record this rule as the rule to use if that
             token follows.  */
          if (bitset_test (LA[state->lookaheadsp + i], j))
-           actrow[j] = -LAruleno[state->lookaheadsp + i];
+           actrow[j] = -LArule[state->lookaheadsp + i]->number;
     }
 
   /* Now see which tokens are allowed for shifts in this state.  For
@@ -395,7 +404,7 @@ action_row (state_t *state)
          for (i = 0; i < state->nlookaheads; i++)
            {
              int count = 0;
-             int rule = -LAruleno[state->lookaheadsp + i];
+             int rule = -LArule[state->lookaheadsp + i]->number;
              int j;
 
              for (j = 0; j < ntokens; j++)
@@ -561,7 +570,7 @@ token_definitions_output (FILE *out)
   int first = 1;
   for (i = 0; i < ntokens; ++i)
     {
-      bucket *symbol = symbols[i];
+      symbol_t *symbol = symbols[i];
       int number = symbol->user_token_number;
 
       if (number == SALIAS)
@@ -918,7 +927,7 @@ output_actions (void)
 
   token_actions ();
   bitsetv_free (LA);
-  XFREE (LAruleno);
+  free (LArule);
 
   goto_actions ();
   XFREE (goto_map + ntokens);