]> git.saurik.com Git - bison.git/blobdiff - src/reader.c
* src/lex.c (percent_table): Add tok_define.
[bison.git] / src / reader.c
index ee859b6a8f9cec607add44224e39eba9fb5f8f89..7e23c0ef94a6537c4554bc9b29928734e6635eda 100644 (file)
@@ -874,6 +874,35 @@ parse_thong_decl (void)
   nsyms--;
 }
 
+/*------------------------------------------.
+| Parse what comes after %header_extension. |
+`------------------------------------------*/
+
+static void
+parse_header_extension_decl (void)
+{
+  char buff[32];
+
+  if (header_extension)
+    complain (_("multiple %%header_extension declarations"));
+  fscanf (finput, "%s", buff);
+  header_extension = xstrdup (buff);
+}
+
+/*------------------------------------------.
+| Parse what comes after %source_extension. |
+`------------------------------------------*/
+
+static void
+parse_source_extension_decl (void)
+{
+  char buff[32];
+
+  if (src_extension)
+    complain (_("multiple %%source_extension declarations"));
+  fscanf (finput, "%s", buff);
+  src_extension = xstrdup (buff);
+}
 
 /*----------------------------------------------------------------.
 | Read from finput until `%%' is seen.  Discard the `%%'.  Handle |
@@ -944,6 +973,14 @@ read_declarations (void)
              parse_assoc_decl (non_assoc);
              break;
 
+           case tok_hdrext:
+             parse_header_extension_decl ();
+             break;
+
+           case tok_srcext:
+             parse_source_extension_decl ();
+             break;
+
            case tok_noop:
              break;
 
@@ -1538,9 +1575,9 @@ readgram (void)
                           "#ifndef YYSTYPE\n#define YYSTYPE int\n#endif\n");
       if (defines_flag)
        obstack_sgrow (&defines_obstack, "\
-#ifndef YYSTYPE\n\
-# define YYSTYPE int\n\
-#endif\n");
+# ifndef YYSTYPE\n\
+#  define YYSTYPE int\n\
+# endif\n");
     }
 
   /* Report any undefined symbols and consider them nonterminals.  */
@@ -1597,11 +1634,11 @@ output_token_defines (struct obstack *oout)
       if (c != '\0')
        continue;
 
-      obstack_fgrow2 (oout, "#define\t%s\t%d\n",
+      obstack_fgrow2 (oout, "# define\t%s\t%d\n",
                      symbol,
                      (translations ? bp->user_token_number : bp->value));
       if (semantic_parser)
-       obstack_fgrow2 (oout, "#define\tT%s\t%d\n", symbol, bp->value);
+       obstack_fgrow2 (oout, "# define\tT%s\t%d\n", symbol, bp->value);
     }
 
   obstack_1grow (oout, '\n');
@@ -1756,7 +1793,7 @@ packsymbols (void)
            /* don't make these for dummy nonterminals made by gensym.  */
            if (*tags[i] != '@')
               obstack_fgrow2 (&defines_obstack,
-                              "#define\tNT%s\t%d\n", tags[i], i);
+                              "# define\tNT%s\t%d\n", tags[i], i);
          }
 #if 0
       /* `fdefines' is now a temporary file, so we need to copy its