mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-10 12:53:03 +00:00
* 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.
This commit is contained in:
16
src/reader.c
16
src/reader.c
@@ -711,6 +711,13 @@ parse_union_decl (void)
|
||||
{
|
||||
int c;
|
||||
int count = 0;
|
||||
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");
|
||||
@@ -723,9 +730,9 @@ parse_union_decl (void)
|
||||
else
|
||||
obstack_1grow (&attrs_obstack, '\n');
|
||||
|
||||
obstack_sgrow (&attrs_obstack, "typedef union");
|
||||
obstack_sgrow (&attrs_obstack, prologue);
|
||||
if (defines_flag)
|
||||
obstack_sgrow (&defines_obstack, "typedef union");
|
||||
obstack_sgrow (&defines_obstack, prologue);
|
||||
|
||||
c = getc (finput);
|
||||
|
||||
@@ -760,9 +767,9 @@ parse_union_decl (void)
|
||||
count--;
|
||||
if (count <= 0)
|
||||
{
|
||||
obstack_sgrow (&attrs_obstack, " YYSTYPE;\n");
|
||||
obstack_sgrow (&attrs_obstack, epilogue);
|
||||
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 != ';')
|
||||
@@ -1955,7 +1962,6 @@ 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');
|
||||
obstack_fgrow3 (&table_obstack, "\
|
||||
/* %s, made from %s\n\
|
||||
by GNU bison %s. */\n\
|
||||
|
||||
Reference in New Issue
Block a user