From 5f7e08323a452b0b55ad94b8c866970a2929d9ad Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 12 Nov 2001 09:24:14 +0000 Subject: [PATCH] * src/bison.simple: Define type yystype instead of YYSTYPE, and define CPP macro, which substitute YYSTYPE by yystype. * src/reader.c (parse_union_decl): Output yystype/YYSTYPE as we do with yyltype/YYLTYPE. This allows inclusion of the generated header within the parser if the compiler, such as GGC, accepts multiple equivalent #defines. From Akim. --- ChangeLog | 10 ++++++++++ src/bison.simple | 3 ++- src/reader.c | 13 +++++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f8a7942..93cc7f02 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2001-11-12 Pascal Bart + + * src/bison.simple: Define type yystype instead of YYSTYPE, and + define CPP macro, which substitute YYSTYPE by yystype. + * src/reader.c (parse_union_decl): Output yystype/YYSTYPE as we do + with yyltype/YYLTYPE. This allows inclusion of the generated + header within the parser if the compiler, such as GGC, accepts + multiple equivalent #defines. + From Akim. + 2001-11-05 Akim Demaille * src/reader.c (symbols_output): New, extracted from... diff --git a/src/bison.simple b/src/bison.simple index 56e63c17..eb94f301 100644 --- a/src/bison.simple +++ b/src/bison.simple @@ -117,7 +117,8 @@ #line %%input_line "%%filename" #ifndef YYSTYPE -typedef %%stype YYSTYPE; +typedef %%stype yystype; +# define YYSTYPE yystype #endif #ifndef YYLTYPE diff --git a/src/reader.c b/src/reader.c index 03c0d311..6206adca 100644 --- a/src/reader.c +++ b/src/reader.c @@ -741,6 +741,13 @@ parse_union_decl (void) int c; int count = 0; struct obstack union_obstack; + const char *prologue = "\ +#ifndef YYSTYPE\n\ +typedef union"; + const char *epilogue = "\ + yystype;\n\ +# define YYSTYPE yystype\n\ +#endif\n"; if (typed) complain (_("multiple %s declarations"), "%union"); @@ -749,13 +756,15 @@ parse_union_decl (void) /* FIXME: I'm worried: are you sure attrs_obstack is properly filled? */ + /* I don't see any reasons to keep this line, because we should + create a special skeleton for this option. */ if (no_lines_flag) obstack_1grow (&attrs_obstack, '\n'); obstack_init (&union_obstack); obstack_sgrow (&union_obstack, "union"); if (defines_flag) - obstack_sgrow (&defines_obstack, "typedef union"); + obstack_sgrow (&defines_obstack, prologue); c = getc (finput); @@ -790,7 +799,7 @@ parse_union_decl (void) if (count <= 0) { if (defines_flag) - obstack_sgrow (&defines_obstack, " YYSTYPE;\n"); + obstack_sgrow (&defines_obstack, epilogue); /* JF don't choke on trailing semi */ c = skip_white_space (); if (c != ';') -- 2.45.2