]> git.saurik.com Git - bison.git/blobdiff - src/output.c
* src/lex.c (literalchar): Don't escape the special characters,
[bison.git] / src / output.c
index dbcfbf0119924a480af72a8880bde8d765f84c92..f38d63bae36c7ee9601e3024292c3f4dcbfe965e 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
 }
 
 
@@ -239,22 +234,14 @@ output_rule_data (void)
 
   j = 0;
   for (i = 0; i < nsyms; i++)
-    /* this used to be i<=nsyms, but that output a final "" symbol
-       almost by accident */
     {
+      /* Be sure not to use twice the same quotearg slot. */
+      const char *cp =
+       quotearg_n_style (1, c_quoting_style,
+                         quotearg_style (escape_quoting_style, tags[i]));
       /* Width of the next token, including the two quotes, the coma
         and the space.  */
-      int strsize = 4;
-      char *p;
-
-      for (p = tags[i]; p && *p; p++)
-       if (*p == '"' || *p == '\\' || *p == '\n' || *p == '\t'
-           || *p == '\b')
-         strsize += 2;
-       else if (*p < 040 || *p >= 0177)
-         strsize += 4;
-       else
-         strsize++;
+      int strsize = strlen (cp) + 2;
 
       if (j + strsize > 75)
        {
@@ -262,24 +249,8 @@ output_rule_data (void)
          j = 2;
        }
 
-      obstack_1grow (&output_obstack, '\"');
-      for (p = tags[i]; p && *p; p++)
-       {
-         if (*p == '"' || *p == '\\')
-           obstack_fgrow1 (&output_obstack, "\\%c", *p);
-         else if (*p == '\n')
-           obstack_sgrow (&output_obstack, "\\n");
-         else if (*p == '\t')
-           obstack_sgrow (&output_obstack, "\\t");
-         else if (*p == '\b')
-           obstack_sgrow (&output_obstack, "\\b");
-         else if (*p < 040 || *p >= 0177)
-           obstack_fgrow1 (&output_obstack, "\\%03o", *p);
-         else
-           obstack_1grow (&output_obstack, *p);
-       }
-
-      obstack_sgrow (&output_obstack, "\", ");
+      obstack_sgrow (&output_obstack, cp);
+      obstack_sgrow (&output_obstack, ", ");
       j += strsize;
     }
   /* add a NULL entry to list of tokens */
@@ -885,6 +856,7 @@ output_check (void)
 static void
 output_actions (void)
 {
+  int i;
   nvectors = nstates + nvars;
 
   froms = XCALLOC (short *, nvectors);
@@ -893,8 +865,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,7 +880,14 @@ output_actions (void)
   output_table ();
 
   output_check ();
-  LIST_FREE (state_t, first_state);
+
+  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);
 }
 
@@ -958,8 +935,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, "%%");
@@ -1028,6 +1003,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);
@@ -1040,8 +1016,6 @@ prepare (void)
   obstack_1grow (&action_obstack, 0);
   muscle_insert ("action", obstack_finish (&action_obstack));
 
-  if (spec_name_prefix)
-    MUSCLE_INSERT_STRING ("prefix", spec_name_prefix);
 }
 
 /*----------------------------------------------------------.
@@ -1063,9 +1037,6 @@ output (void)
   XFREE (user_toknums);
   output_actions ();
 
-#if 0
-  if (!no_parser_flag) */
-#endif
   prepare ();
   /* Copy definitions in directive.  */
   obstack_1grow (&attrs_obstack, 0);