[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: FYI: Both: Protect YYSTYPE
From: |
Pascal Bart |
Subject: |
Re: FYI: Both: Protect YYSTYPE |
Date: |
Thu, 8 Nov 2001 23:08:13 +0000 (GMT) |
Hello Akim,
>Well, I am unable to apply this patch to the trunk, the code is too
>different. Also, I don't understand it well enough for the moment to
>do that. So, could someone port this patch to the trunk?
I've converted your patch, but I can't test it today, so probably I will
apply it in few days. But this code should be changed later, it generates
C code for the header, in the future I hope we could introduce something
like header skeleton.
Probably, we could talk about that with a beer ;).
Index: ChangeLog
===================================================================
RCS file: /cvsroot/bison/bison/ChangeLog,v
retrieving revision 1.240
diff -u -r1.240 ChangeLog
--- ChangeLog 2001/11/05 14:19:29 1.240
+++ ChangeLog 2001/11/08 21:56:07
@@ -1,3 +1,13 @@
+2001-11-08 Pascal Bart <address@hidden>
+
+ * 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 <address@hidden>
* src/reader.c (symbols_output): New, extracted from...
Index: src/bison.simple
===================================================================
RCS file: /cvsroot/bison/bison/src/bison.simple,v
retrieving revision 1.70
diff -u -r1.70 bison.simple
--- src/bison.simple 2001/10/10 14:58:26 1.70
+++ src/bison.simple 2001/11/08 21:56:11
@@ -117,7 +117,8 @@
#line %%input_line "%%filename"
#ifndef YYSTYPE
-typedef %%stype YYSTYPE;
+typedef %%stype yystype;
+# define YYSTYPE yystype
#endif
#ifndef YYLTYPE
Index: src/reader.c
===================================================================
RCS file: /cvsroot/bison/bison/src/reader.c,v
retrieving revision 1.95
diff -u -r1.95 reader.c
--- src/reader.c 2001/11/05 14:19:29 1.95
+++ src/reader.c 2001/11/08 21:56:17
@@ -741,6 +741,13 @@
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 @@
/* 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 @@
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 != ';')
Pascal Bart (address@hidden)