]> git.saurik.com Git - bison.git/commitdiff
* src/bison.simple: Add %%user_code directive at the end.
authorMarc Autret <autret_m@epita.fr>
Wed, 29 Aug 2001 14:17:00 +0000 (14:17 +0000)
committerMarc Autret <autret_m@epita.fr>
Wed, 29 Aug 2001 14:17:00 +0000 (14:17 +0000)
* src/reader.c (read_additionnal_code): New.
(reader): Use it.
* src/output.c (output_program): Remove.
(output): Update.

ChangeLog
src/bison.simple
src/output.c
src/reader.c

index cb02468a1fac1ebbd9e5e3f495a6484fe5e36fb6..d35daa297dedfb9666b694d07c60f6ca9d939a1d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2001-08-29  Marc Autret  <autret_m@epita.fr>
+
+       * src/bison.simple: Add %%user_code directive at the end.
+       * src/reader.c (read_additionnal_code): New.
+       (reader): Use it.
+       * src/output.c (output_program): Remove.
+       (output): Update.
+
 2001-08-28  Marc Autret  <autret_m@epita.fr>
 
        * src/output.c (output_actions): Clean up.
 2001-08-28  Marc Autret  <autret_m@epita.fr>
 
        * src/output.c (output_actions): Clean up.
index 700a9edbda4b3a4fda410deb4155c7b37444a783..d6268630ba8229024eaf588b08ca44d1031be4c4 100644 (file)
@@ -976,3 +976,6 @@ yyabortlab:
     }
   return 1;
 }
     }
   return 1;
 }
+
+%%user_code
+
index b58f0ec043c19d0d6b7b387814880446ecd7e332..21711cb1404fb39b62bff767c6e231d1c50e126a 100644 (file)
@@ -1017,16 +1017,6 @@ output_parser (void)
   xfclose (fskel);
 }
 
   xfclose (fskel);
 }
 
-static void
-output_program (void)
-{
-  int c;
-
-  while ((c = getc (finput)) != EOF)
-    obstack_1grow (&table_obstack, c);
-}
-
-
 static void
 free_itemsets (void)
 {
 static void
 free_itemsets (void)
 {
@@ -1122,7 +1112,6 @@ output (void)
   /* Copy definitions in directive.  */
   macro_insert ("definitions", obstack_finish (&attrs_obstack));
   output_parser ();
   /* Copy definitions in directive.  */
   macro_insert ("definitions", obstack_finish (&attrs_obstack));
   output_parser ();
-  output_program ();
 
   obstack_free (&macro_obstack, 0);
   obstack_free (&output_obstack, 0);
 
   obstack_free (&macro_obstack, 0);
   obstack_free (&output_obstack, 0);
index 282611d777eeca3b383016311569d941038cfbd3..8fa3dfe833cd10e38e5b1774c5950d17d3f2df16 100644 (file)
@@ -1667,6 +1667,25 @@ readgram (void)
 
   ntokens = nsyms - nvars;
 }
 
   ntokens = nsyms - nvars;
 }
+
+/* At the end of the grammar file, some C source code must
+   be stored. It is going to be associated to the user_code
+   directive.  */
+static void
+read_additionnal_code (void)
+{
+  char c;
+  struct obstack uc_obstack;
+  
+  obstack_init (&uc_obstack);
+
+  while ((c = getc (finput)) != EOF)
+    obstack_1grow (&uc_obstack, c);
+  
+  obstack_1grow (&uc_obstack, 0);
+  macro_insert ("user_code", obstack_finish (&uc_obstack));
+}
+
 \f
 /*--------------------------------------------------------------.
 | For named tokens, but not literal ones, define the name.  The |
 \f
 /*--------------------------------------------------------------.
 | For named tokens, but not literal ones, define the name.  The |
@@ -2016,6 +2035,8 @@ reader (void)
   /* Read in the grammar, build grammar in list form.  Write out
      guards and actions.  */
   readgram ();
   /* Read in the grammar, build grammar in list form.  Write out
      guards and actions.  */
   readgram ();
+  /* Some C code is given at the end of the grammar file. */
+  read_additionnal_code ();
   /* Now we know whether we need the line-number stack.  If we do,
      write its type into the .tab.h file.  */
 #if 0
   /* Now we know whether we need the line-number stack.  If we do,
      write its type into the .tab.h file.  */
 #if 0