]> git.saurik.com Git - bison.git/blobdiff - src/output.c
Some hosts don't like `/' in includes.
[bison.git] / src / output.c
index 693a45b14bc22bbe0c1e729b4dfc1862412731dd..b1dd19c03646a2520211795ac297fca3655dd533 100644 (file)
@@ -198,11 +198,6 @@ output_gram (void)
 
     XFREE (yyrhs);
   }
-
-#if 0
-  if (!semantic_parser && !no_parser_flag)
-    obstack_sgrow (&table_obstack, "\n#endif\n");
-#endif
 }
 
 
@@ -212,7 +207,7 @@ output_stos (void)
   int i;
   short *values = (short *) alloca (sizeof (short) * nstates);
   for (i = 0; i < nstates; ++i)
-    values[i] = state_table[i].accessing_symbol;
+    values[i] = state_table[i]->accessing_symbol;
   output_table_data (&output_obstack, values,
                     0, 1, nstates);
   muscle_insert ("stos", obstack_finish (&output_obstack));
@@ -355,7 +350,7 @@ action_row (int state)
 
   default_rule = 0;
   nreds = 0;
-  redp = state_table[state].reductions;
+  redp = state_table[state]->reductions;
 
   if (redp)
     {
@@ -365,8 +360,8 @@ action_row (int state)
        {
          /* loop over all the rules available here which require
             lookahead */
-         m = state_table[state].lookaheads;
-         n = state_table[state + 1].lookaheads;
+         m = state_table[state]->lookaheads;
+         n = state_table[state + 1]->lookaheads;
 
          for (i = n - 1; i >= m; i--)
            /* and find each token which the rule finds acceptable
@@ -382,14 +377,14 @@ action_row (int state)
   /* Now see which tokens are allowed for shifts in this state.  For
      them, record the shift as the thing to do.  So shift is preferred
      to reduce.  */
-  shiftp = state_table[state].shifts;
+  shiftp = state_table[state]->shifts;
   for (i = 0; i < shiftp->nshifts; i++)
     {
       shift_state = shiftp->shifts[i];
       if (!shift_state)
        continue;
 
-      symbol = state_table[shift_state].accessing_symbol;
+      symbol = state_table[shift_state]->accessing_symbol;
 
       if (ISVAR (symbol))
        break;
@@ -404,7 +399,7 @@ action_row (int state)
 
   /* See which tokens are an explicit error in this state (due to
      %nonassoc).  For them, record MINSHORT as the action.  */
-  errp = state_table[state].errs;
+  errp = state_table[state]->errs;
 
   if (errp)
     {
@@ -422,7 +417,7 @@ action_row (int state)
 
   if (nreds >= 1 && !nodefault)
     {
-      if (state_table[state].consistent)
+      if (state_table[state]->consistent)
        default_rule = redp->rules[0];
       else
        {
@@ -885,6 +880,7 @@ output_check (void)
 static void
 output_actions (void)
 {
+  int i;
   nvectors = nstates + nvars;
 
   froms = XCALLOC (short *, nvectors);
@@ -893,8 +889,6 @@ output_actions (void)
   width = XCALLOC (short, nvectors);
 
   token_actions ();
-  LIST_FREE (shifts, first_shift);
-  LIST_FREE (reductions, first_reduction);
   XFREE (LA);
   XFREE (LAruleno);
 
@@ -910,6 +904,14 @@ output_actions (void)
   output_table ();
 
   output_check ();
+
+  for (i = 0; i < nstates; ++i)
+    {
+      XFREE (state_table[i]->shifts);
+      XFREE (state_table[i]->reductions);
+      XFREE (state_table[i]->errs);
+      free (state_table[i]);
+    }
   XFREE (state_table);
 }
 
@@ -957,8 +959,6 @@ output_parser (const char *skel_filename, struct obstack *oout)
            obstack_sgrow (oout, muscle_value);
          else if (!strcmp (muscle_key, "line"))
            obstack_fgrow1 (oout, "%d", line + 1);
-         else if (!strcmp (muscle_key, "input-line"))
-           obstack_fgrow1 (oout, "%d", lineno);
          else
            {
              obstack_sgrow (oout, "%%");
@@ -1027,6 +1027,7 @@ prepare (void)
   MUSCLE_INSERT_INT ("maxtok", max_user_token_number);
   MUSCLE_INSERT_INT ("ntbase", ntokens);
   MUSCLE_INSERT_INT ("error-verbose", error_verbose);
+  MUSCLE_INSERT_STRING ("prefix", spec_name_prefix);
 
   MUSCLE_INSERT_INT ("nnts", nvars);
   MUSCLE_INSERT_INT ("nrules", nrules);
@@ -1036,10 +1037,9 @@ prepare (void)
   MUSCLE_INSERT_INT ("locations-flag", locations_flag);
 
   /* We need to save the actions in the muscle %%action.  */
+  obstack_1grow (&action_obstack, 0);
   muscle_insert ("action", obstack_finish (&action_obstack));
 
-  if (spec_name_prefix)
-    MUSCLE_INSERT_STRING ("prefix", spec_name_prefix);
 }
 
 /*----------------------------------------------------------.
@@ -1051,8 +1051,6 @@ output (void)
 {
   obstack_init (&output_obstack);
 
-  LIST_FREE (core, first_state);
-
   output_token_translations ();
   output_gram ();
 
@@ -1063,11 +1061,9 @@ output (void)
   XFREE (user_toknums);
   output_actions ();
 
-#if 0
-  if (!no_parser_flag) */
-#endif
   prepare ();
   /* Copy definitions in directive.  */
+  obstack_1grow (&attrs_obstack, 0);
   muscle_insert ("prologue", obstack_finish (&attrs_obstack));
 
   output_master_parser ();