]> git.saurik.com Git - bison.git/commitdiff
* src/files.c (action_obstack): Remove, unused.
authorAkim Demaille <akim@epita.fr>
Fri, 14 Jun 2002 17:36:24 +0000 (17:36 +0000)
committerAkim Demaille <akim@epita.fr>
Fri, 14 Jun 2002 17:36:24 +0000 (17:36 +0000)
(output_obstack): Remove it, and all its dependencies, as it is no
longer needed.
* src/reader.c (epilogue_set): Build the epilogue in the
muscle_obstack.
* src/output.h, src/output.c (muscle_obstack): Move to...
* src/muscle_tab.h, src/muscle_tab.h: here.
(muscle_init): Initialize muscle_obstack.
(muscle_free): New.
* src/main.c (main): Call it.

ChangeLog
src/files.c
src/files.h
src/main.c
src/muscle_tab.c
src/muscle_tab.h
src/output.c
src/output.h
src/print.c
src/reader.c

index f9ea0e12ae5da884d085924b277dd02e2baee7e1..8c6deb906ee51db961a824f590ef360009b04b79 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2002-06-14  Akim Demaille  <akim@epita.fr>
+
+       * src/files.c (action_obstack): Remove, unused.
+       (output_obstack): Remove it, and all its dependencies, as it is no
+       longer needed.
+       * src/reader.c (epilogue_set): Build the epilogue in the
+       muscle_obstack.
+       * src/output.h, src/output.c (muscle_obstack): Move to...
+       * src/muscle_tab.h, src/muscle_tab.h: here.
+       (muscle_init): Initialize muscle_obstack.
+       (muscle_free): New.
+       * src/main.c (main): Call it.
+
+       
 2002-06-14  Akim Demaille  <akim@epita.fr>
 
        * src/location.h: New, extracted from...
 2002-06-14  Akim Demaille  <akim@epita.fr>
 
        * src/location.h: New, extracted from...
index 1e084f6ec253ed7ed61c5ac7eefe1d42d798cfea..f6e80db8471a5ac8249332db01fa7977714d652a 100644 (file)
@@ -1,5 +1,5 @@
 /* Open and close files for bison,
 /* Open and close files for bison,
-   Copyright 1984, 1986, 1989, 1992, 2000, 2001, 2002
+   Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002
    Free Software Foundation, Inc.
 
    This file is part of Bison, the GNU Compiler Compiler.
    Free Software Foundation, Inc.
 
    This file is part of Bison, the GNU Compiler Compiler.
@@ -32,8 +32,6 @@ const char *base_name PARAMS ((char const *name));
 
 FILE *finput = NULL;
 
 
 FILE *finput = NULL;
 
-struct obstack action_obstack;
-struct obstack output_obstack;
 struct obstack pre_prologue_obstack;
 struct obstack post_prologue_obstack;
 
 struct obstack pre_prologue_obstack;
 struct obstack post_prologue_obstack;
 
index d5d286c5a13314f23c8d7de108610d4c4fad3ff6..0ab2086e431f83d9012ab9ae7ed104e6411c3908 100644 (file)
@@ -46,16 +46,10 @@ extern char *spec_defines_file;
 extern FILE *finput;
 
 
 extern FILE *finput;
 
 
-/* Output all the action code; precise form depends on which parser. */
-extern struct obstack action_obstack;
-
 /* If semantic parser, output a .h file that defines YYSTYPE... */
 extern struct obstack pre_prologue_obstack;
 extern struct obstack post_prologue_obstack;
 
 /* If semantic parser, output a .h file that defines YYSTYPE... */
 extern struct obstack pre_prologue_obstack;
 extern struct obstack post_prologue_obstack;
 
-/* The verbose output. */
-extern struct obstack output_obstack;
-
 extern char *infile;
 
 void compute_output_file_names PARAMS((void));
 extern char *infile;
 
 void compute_output_file_names PARAMS((void));
index 9421df913f9d3dc553431a3975ca6fb6e043eee7..9cdd581811a6392ce62f21088a57e7c3cbb0c8d7 100644 (file)
@@ -110,7 +110,7 @@ main (int argc, char *argv[])
   free_nullable ();
   free_derives ();
   grammar_free ();
   free_nullable ();
   free_derives ();
   grammar_free ();
-
+  muscle_free ();
   /* If using alloca.c, flush the alloca'ed memory for the benefit of
      people running Bison as a library in IDEs.  */
 #if C_ALLOCA
   /* If using alloca.c, flush the alloca'ed memory for the benefit of
      people running Bison as a library in IDEs.  */
 #if C_ALLOCA
index b556ef73136ba75809ce4651e161481c86751ea4..895e2e3e184f899f8b436f5996eac3633367da33 100644 (file)
 #include "muscle_tab.h"
 #include "getargs.h"
 
 #include "muscle_tab.h"
 #include "getargs.h"
 
+
+/* An obstack used to create some entries.  */
+struct obstack muscle_obstack;
+
 /* Initial capacity of muscles hash table.  */
 #define HT_INITIAL_CAPACITY 257
 
 /* Initial capacity of muscles hash table.  */
 #define HT_INITIAL_CAPACITY 257
 
@@ -44,16 +48,24 @@ hash_muscle (const void *x, unsigned int tablesize)
   return hash_string (m->key, tablesize);
 }
 
   return hash_string (m->key, tablesize);
 }
 
+/*-----------------------------------------------------------------.
+| Create the MUSCLE_TABLE, and initialize it with default values.  |
+| Also set up the MUSCLE_OBSTACK.                                  |
+`-----------------------------------------------------------------*/
+
 void
 muscle_init (void)
 {
   muscle_table = hash_initialize (HT_INITIAL_CAPACITY, NULL, hash_muscle,
 void
 muscle_init (void)
 {
   muscle_table = hash_initialize (HT_INITIAL_CAPACITY, NULL, hash_muscle,
-                                 hash_compare_muscles, NULL);
+                                 hash_compare_muscles, free);
 
   /* Version and input file.  */
   muscle_insert ("version", VERSION);
   muscle_insert ("filename", infile);
 
 
   /* Version and input file.  */
   muscle_insert ("version", VERSION);
   muscle_insert ("filename", infile);
 
+  /* FIXME: there should probably be no default here, only in the
+     skeletons.  */
+
   /* Types.  */
   muscle_insert ("ltype", "yyltype");
 
   /* Types.  */
   muscle_insert ("ltype", "yyltype");
 
@@ -66,8 +78,25 @@ muscle_init (void)
 
   /* C++ macros.  */
   muscle_insert ("name", "Parser");
 
   /* C++ macros.  */
   muscle_insert ("name", "Parser");
+
+  /* Initialize the muscle obstack.  */
+  obstack_init (&muscle_obstack);
 }
 
 }
 
+
+/*------------------------------------------------------------.
+| Free all the memory consumed by the muscle machinery only.  |
+`------------------------------------------------------------*/
+
+void
+muscle_free (void)
+{
+  hash_free (muscle_table);
+  obstack_free (&muscle_obstack, NULL);
+}
+
+
+
 void
 muscle_insert (const char *key, const char *value)
 {
 void
 muscle_insert (const char *key, const char *value)
 {
index 68bc9e7bd66c68b2ab958ebcaf3b14c6f818b62b..f4a0b96ad6810bb354583b73c95422b111b19b16 100644 (file)
@@ -32,6 +32,11 @@ typedef struct muscle_entry_s
 void muscle_init PARAMS ((void));
 void muscle_insert PARAMS ((const char *key, const char *value));
 const char *muscle_find PARAMS ((const char *key));
 void muscle_init PARAMS ((void));
 void muscle_insert PARAMS ((const char *key, const char *value));
 const char *muscle_find PARAMS ((const char *key));
+void muscle_free PARAMS ((void));
+
+
+/* An obstack dedicated to receive muscle keys and values.  */
+extern struct obstack muscle_obstack;
 
 #define MUSCLE_INSERT_INT(Key, Value)                          \
 {                                                              \
 
 #define MUSCLE_INSERT_INT(Key, Value)                          \
 {                                                              \
index 5645e8cdcd9f69efc9bf2af152a38b349f625e12..0cfadc80e72bee135999a8333f6d5ecd5eeb9a41 100644 (file)
@@ -132,7 +132,6 @@ static short *check = NULL;
 static int lowzero;
 static int high;
 
 static int lowzero;
 static int high;
 
-struct obstack muscle_obstack;
 static struct obstack format_obstack;
 
 int error_verbose = 0;
 static struct obstack format_obstack;
 
 int error_verbose = 0;
@@ -1087,9 +1086,7 @@ output (void)
   /* Process the selected skeleton file.  */
   output_skeleton ();
 
   /* Process the selected skeleton file.  */
   output_skeleton ();
 
-  obstack_free (&muscle_obstack, NULL);
   obstack_free (&format_obstack, NULL);
   obstack_free (&format_obstack, NULL);
-  obstack_free (&action_obstack, NULL);
   obstack_free (&pre_prologue_obstack, NULL);
   obstack_free (&post_prologue_obstack, NULL);
 }
   obstack_free (&pre_prologue_obstack, NULL);
   obstack_free (&post_prologue_obstack, NULL);
 }
index d12c125d0e2ab01463e98bc19027e059f7d5a54a..67d5078fb3af5d3f442d9dfaf060f10f0d5a04e8 100644 (file)
@@ -29,6 +29,4 @@ void output PARAMS ((void));
 void actions_output PARAMS ((FILE *out));
 void token_definitions_output PARAMS ((FILE *out));
 
 void actions_output PARAMS ((FILE *out));
 void token_definitions_output PARAMS ((FILE *out));
 
-extern struct obstack muscle_obstack;
-
 #endif /* !OUTPUT_H_ */
 #endif /* !OUTPUT_H_ */
index d8a4f008c6c8a9b61427e62cfe75fff1602fd398..3c5d0ba3e78e7ac6fba79ff8868833e4ccdbbe6c 100644 (file)
@@ -503,13 +503,6 @@ print_results (void)
      that conflicts with Posix.  */
   FILE *out = xfopen (spec_verbose_file, "w");
 
      that conflicts with Posix.  */
   FILE *out = xfopen (spec_verbose_file, "w");
 
-  size_t size = obstack_object_size (&output_obstack);
-  fwrite (obstack_finish (&output_obstack), 1, size, out);
-  obstack_free (&output_obstack, NULL);
-
-  if (size)
-    fputs ("\n\n", out);
-
   reduce_output (out);
   conflicts_output (out);
 
   reduce_output (out);
   conflicts_output (out);
 
index 12bb2d67f82048d1e1f321c22ae8be32a44cd8ab..ad76ee10b2dddba2f13bd5d9974716587723bc39 100644 (file)
@@ -138,19 +138,16 @@ prologue_augment (const char *prologue, location_t location)
 void
 epilogue_set (const char *epilogue, location_t location)
 {
 void
 epilogue_set (const char *epilogue, location_t location)
 {
-  struct obstack el_obstack;
-  obstack_init (&el_obstack);
-
   if (!no_lines_flag)
     {
   if (!no_lines_flag)
     {
-      obstack_fgrow2 (&el_obstack, muscle_find ("linef"),
+      obstack_fgrow2 (&muscle_obstack, muscle_find ("linef"),
                      location.first_line,
                      quotearg_style (c_quoting_style,
                                      muscle_find ("filename")));
     }
                      location.first_line,
                      quotearg_style (c_quoting_style,
                                      muscle_find ("filename")));
     }
-  obstack_sgrow (&el_obstack, epilogue);
-  obstack_1grow (&el_obstack, 0);
-  muscle_insert ("epilogue", obstack_finish (&el_obstack));
+  obstack_sgrow (&muscle_obstack, epilogue);
+  obstack_1grow (&muscle_obstack, 0);
+  muscle_insert ("epilogue", obstack_finish (&muscle_obstack));
 }
 
 
 }
 
 
@@ -450,9 +447,6 @@ reader (void)
   gram_control_t gram_control;
   lineno = 1;
 
   gram_control_t gram_control;
   lineno = 1;
 
-  /* Initialize the muscle obstack.  */
-  obstack_init (&muscle_obstack);
-
   /* Initialize the symbol table.  */
   symbols_new ();
 
   /* Initialize the symbol table.  */
   symbols_new ();
 
@@ -473,8 +467,6 @@ reader (void)
   undeftoken->number = ntokens++;
 
   /* Initialize the obstacks. */
   undeftoken->number = ntokens++;
 
   /* Initialize the obstacks. */
-  obstack_init (&action_obstack);
-  obstack_init (&output_obstack);
   obstack_init (&pre_prologue_obstack);
   obstack_init (&post_prologue_obstack);
 
   obstack_init (&pre_prologue_obstack);
   obstack_init (&post_prologue_obstack);