]> git.saurik.com Git - bison.git/blobdiff - src/reader.c
* src/reader.c (reader): Delete obsolete call to function
[bison.git] / src / reader.c
index cc8f90a0eea7bdfb72d21b6cc4d482bce1ca5171..e46d5fab976684a52389be864c18c7ecd0f5425b 100644 (file)
@@ -907,9 +907,6 @@ parse_macro_decl (void)
   int ch = ungetc (skip_white_space (), finput);
   char* macro_key;
   char* macro_value;
-  struct obstack macro_obstack;
-
-  obstack_init (&macro_obstack);
 
   /* Read key. */
   if (!isalpha (ch) && ch != '_')
@@ -919,6 +916,7 @@ parse_macro_decl (void)
       return;
     }
   copy_identifier (finput, &macro_obstack);
+  obstack_1grow (&macro_obstack, 0);
   macro_key = obstack_finish (&macro_obstack);
   
   /* Read value. */
@@ -935,15 +933,25 @@ parse_macro_decl (void)
       else
        fatal (_("Premature EOF after %s"), "\"");
     }
-  copy_string (finput, &macro_obstack, '"');
+  copy_string2 (finput, &macro_obstack, '"', 0);
+  obstack_1grow (&macro_obstack, 0);
   macro_value = obstack_finish (&macro_obstack);
 
-  obstack_free (&macro_obstack, 0);
-
   /* Store the (key, value) pair in the environment. */
   macro_insert (macro_key, macro_value);
 }
 
+
+/*----------------------------------.
+| Parse what comes after %skeleton. |
+`----------------------------------*/
+
+void
+parse_skel_decl (void)
+{
+  /* Complete with parse_dquoted_param () on the CVS branch 1.29.  */
+}
+
 /*------------------------------------------.
 | Parse what comes after %header_extension. |
 `------------------------------------------*/
@@ -1054,6 +1062,10 @@ read_declarations (void)
            case tok_define:
              parse_macro_decl ();
              break;
+             
+           case tok_skel:
+             parse_skel_decl ();
+             break;
 
            case tok_noop:
              break;
@@ -1670,6 +1682,25 @@ readgram (void)
 
   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 |
@@ -1991,6 +2022,9 @@ reader (void)
   init_lex ();
   lineno = 1;
 
+  /* Initialize the macro obstack.  */
+  obstack_init (&macro_obstack);
+
   /* Initialize the symbol table.  */
   tabinit ();
 
@@ -2008,22 +2042,23 @@ reader (void)
   /* Read the declaration section.  Copy %{ ... %} groups to
      TABLE_OBSTACK and FDEFINES file.  Also notice any %token, %left,
      etc. found there.  */
-  /* obstack_1grow (&table_obstack, '\n'); */
-
   read_declarations ();
-  /* Start writing the guard and action files, if they are needed.  */
-  /* output_headers (); */
   /* 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 (defines_flag)
-     reader_output_yylsp (&defines_obstack); */
+#if 0
+  if (defines_flag)
+    reader_output_yylsp (&defines_obstack);
+#endif
   /* Write closing delimiters for actions and guards.  */
-  /* output_trailers (); */
-  /* if (locations_flag)
-     obstack_sgrow (&table_obstack, "#define YYLSP_NEEDED 1\n\n"); */
+#if 0
+  if (locations_flag)
+    obstack_sgrow (&table_obstack, "#define YYLSP_NEEDED 1\n\n");
+#endif
   /* Assign the symbols their symbol numbers.  Write #defines for the
      token symbols into FDEFINES if requested.  */
   packsymbols ();