From 180d45ba81510aee0de19f20fc6069b9681abe3c Mon Sep 17 00:00:00 2001 From: Pascal Bart Date: Sun, 23 Sep 2001 15:33:14 +0000 Subject: [PATCH] * src/reader.c (parse_union_decl): Add new obstack union_obstack. Which will contain `%union' declaration. (parse_union_decl): Delete #line directive output. (parse_union_decl): Substitute /attrs_obstack/union_obstack for all informations about %union. (parse_union_decl): Copy the union_obstack in the muscle stype. * src/bison.simple: Add new #line directive. Add typdef %%stype YYSTYPE. --- ChangeLog | 11 +++++++++++ src/bison.simple | 3 ++- src/reader.c | 27 ++++++++++++--------------- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3d44a0a7..b2db6979 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2001-09-23 Pascal Bart + + * src/reader.c (parse_union_decl): Add new obstack union_obstack. Which + will contain `%union' declaration. + (parse_union_decl): Delete #line directive output. + (parse_union_decl): Substitute /attrs_obstack/union_obstack for all + informations about %union. + (parse_union_decl): Copy the union_obstack in the muscle stype. + * src/bison.simple: Add new #line directive. + Add typdef %%stype YYSTYPE. + 2001-09-23 Pascal Bart * src/bison.simple: Add new `#line' directive. diff --git a/src/bison.simple b/src/bison.simple index 5b980d18..9c1a8c12 100644 --- a/src/bison.simple +++ b/src/bison.simple @@ -111,8 +111,9 @@ # define YYDEBUG %%debug #endif +#line %%input_line "%%filename" #ifndef YYSTYPE -# define YYSTYPE %%stype +typedef %%stype YYSTYPE; #endif #ifndef YYLTYPE diff --git a/src/reader.c b/src/reader.c index 5344837a..35e08501 100644 --- a/src/reader.c +++ b/src/reader.c @@ -735,9 +735,9 @@ token_buffer); /*--------------------------------------------------------------. -| Copy the union declaration into ATTRS_OBSTACK (and fdefines), | -| where it is made into the definition of YYSTYPE, the type of | -| elements of the parser value stack. | +| Copy the union declaration into the stype muscle | +| (and fdefines), where it is made into the definition of | +| YYSTYPE, the type of elements of the parser value stack. | `--------------------------------------------------------------*/ static void @@ -745,23 +745,18 @@ parse_union_decl (void) { int c; int count = 0; + struct obstack union_obstack; if (typed) complain (_("multiple %s declarations"), "%union"); typed = 1; - - if (!no_lines_flag) - { - obstack_fgrow2 (&attrs_obstack, muscle_find ("linef"), - lineno, quotearg_style (c_quoting_style, - muscle_find("filename"))); - } - else + if (no_lines_flag) obstack_1grow (&attrs_obstack, '\n'); - obstack_sgrow (&attrs_obstack, "typedef union"); + obstack_init (&union_obstack); + obstack_sgrow (&union_obstack, "union"); if (defines_flag) obstack_sgrow (&defines_obstack, "typedef union"); @@ -769,7 +764,7 @@ parse_union_decl (void) while (c != EOF) { - obstack_1grow (&attrs_obstack, c); + obstack_1grow (&union_obstack, c); if (defines_flag) obstack_1grow (&defines_obstack, c); @@ -780,7 +775,7 @@ parse_union_decl (void) break; case '/': - copy_comment2 (finput, &defines_obstack, &attrs_obstack); + copy_comment2 (finput, &defines_obstack, &union_obstack); break; case '{': @@ -793,19 +788,21 @@ parse_union_decl (void) count--; if (count <= 0) { - obstack_sgrow (&attrs_obstack, " YYSTYPE;\n"); if (defines_flag) obstack_sgrow (&defines_obstack, " YYSTYPE;\n"); /* JF don't choke on trailing semi */ c = skip_white_space (); if (c != ';') ungetc (c, finput); + obstack_1grow (&union_obstack, 0); + muscle_insert ("stype", obstack_finish (&union_obstack)); return; } } c = getc (finput); } + } -- 2.45.2