X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/b0ce6046682724c333e1444c86dfcfe3d51d8264..dd3127cf7a8534b1689d19452e310138d8db784f:/src/reader.c diff --git a/src/reader.c b/src/reader.c index ee859b6a..7e23c0ef 100644 --- a/src/reader.c +++ b/src/reader.c @@ -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