]> git.saurik.com Git - bison.git/commitdiff
* src/reader.c (parse_union_decl): Output yystype/YYSTYPE as we do
authorAkim Demaille <akim@epita.fr>
Mon, 5 Nov 2001 09:12:38 +0000 (09:12 +0000)
committerAkim Demaille <akim@epita.fr>
Mon, 5 Nov 2001 09:12:38 +0000 (09:12 +0000)
with yyltype/YYLTYPE.  This allows inclusion of the generated
header within the parser if the compiler, such as GGC, accepts
multiple equivalent #defines.

ChangeLog
doc/bison.info-1
doc/bison.texinfo
doc/stamp-vti
doc/version.texi
src/reader.c

index c391cafecb61ea2ad7f08124ccc15ec36b795784..cbb8e1cb39908f2699d85aa0585d9bf15cfb338e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2001-11-05  Akim Demaille  <akim@epita.fr>
+
+       * 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.
+
 2001-11-04  Akim Demaille  <akim@epita.fr>
 
        * src/getargs.c (longopts): Support `--output'.  getopt is now
 2001-11-04  Akim Demaille  <akim@epita.fr>
 
        * src/getargs.c (longopts): Support `--output'.  getopt is now
index 894f803215e154e8be46bc831699efdfaa8ef1f3..6f3a9a71ce235fb1bc36182ff67698bf1662375e 100644 (file)
@@ -34,7 +34,7 @@ File: bison.info,  Node: Top,  Next: Introduction,  Up: (dir)
 Bison
 *****
 
 Bison
 *****
 
-   This manual documents version 1.30a of Bison, updated 4 November
+   This manual documents version 1.30a of Bison, updated 5 November
 2001.
 
 * Menu:
 2001.
 
 * Menu:
index 73a43d6d4119f3e9e87969e98298d8c749ba749f..d0a44bb1f5e8eeb6b9a830186d70133d408233d3 100644 (file)
@@ -855,11 +855,12 @@ The C declarations section (@pxref{C Declarations, ,The C Declarations Section})
 preprocessor directives.
 
 The @code{#define} directive defines the macro @code{YYSTYPE}, thus
 preprocessor directives.
 
 The @code{#define} directive defines the macro @code{YYSTYPE}, thus
-specifying the C data type for semantic values of both tokens and groupings
-(@pxref{Value Type, ,Data Types of Semantic Values}).  The Bison parser will use whatever type
-@code{YYSTYPE} is defined as; if you don't define it, @code{int} is the
-default.  Because we specify @code{double}, each token and each expression
-has an associated value, which is a floating point number.
+specifying the C data type for semantic values of both tokens and
+groupings (@pxref{Value Type, ,Data Types of Semantic Values}).  The
+Bison parser will use whatever type @code{YYSTYPE} is defined as; if you
+don't define it, @code{int} is the default.  Because we specify
+@code{double}, each token and each expression has an associated value,
+which is a floating point number.
 
 The @code{#include} directive is used to declare the exponentiation
 function @code{pow}.
 
 The @code{#include} directive is used to declare the exponentiation
 function @code{pow}.
@@ -1066,10 +1067,11 @@ token type is an identifier, that identifier is defined by Bison as a C
 macro whose definition is the appropriate number.  In this example,
 therefore, @code{NUM} becomes a macro for @code{yylex} to use.
 
 macro whose definition is the appropriate number.  In this example,
 therefore, @code{NUM} becomes a macro for @code{yylex} to use.
 
-The semantic value of the token (if it has one) is stored into the global
-variable @code{yylval}, which is where the Bison parser will look for it.
-(The C data type of @code{yylval} is @code{YYSTYPE}, which was defined
-at the beginning of the grammar; @pxref{Rpcalc Decls, ,Declarations for @code{rpcalc}}.)
+The semantic value of the token (if it has one) is stored into the
+global variable @code{yylval}, which is where the Bison parser will look
+for it.  (The C data type of @code{yylval} is @code{YYSTYPE}, which was
+defined at the beginning of the grammar; @pxref{Rpcalc Decls,
+,Declarations for @code{rpcalc}}.)
 
 A token type code of zero is returned if the end-of-file is encountered.
 (Bison recognizes any nonpositive value as indicating the end of the
 
 A token type code of zero is returned if the end-of-file is encountered.
 (Bison recognizes any nonpositive value as indicating the end of the
@@ -2374,7 +2376,8 @@ the numbers associated with @var{x} and @var{y}.
 
 In a simple program it may be sufficient to use the same data type for
 the semantic values of all language constructs.  This was true in the
 
 In a simple program it may be sufficient to use the same data type for
 the semantic values of all language constructs.  This was true in the
-RPN and infix calculator examples (@pxref{RPN Calc, ,Reverse Polish Notation Calculator}).
+RPN and infix calculator examples (@pxref{RPN Calc, ,Reverse Polish
+Notation Calculator}).
 
 Bison's default is to use type @code{int} for all semantic values.  To
 specify some other type, define @code{YYSTYPE} as a macro, like this:
 
 Bison's default is to use type @code{int} for all semantic values.  To
 specify some other type, define @code{YYSTYPE} as a macro, like this:
index 5f289e5866ebba9a1817db6a62ea4bb9733fcf61..2a4a4194fcffc7f29b035936779c730acba13f40 100644 (file)
@@ -1,4 +1,4 @@
-@set UPDATED 4 November 2001
+@set UPDATED 5 November 2001
 @set UPDATED-MONTH November 2001
 @set EDITION 1.30a
 @set VERSION 1.30a
 @set UPDATED-MONTH November 2001
 @set EDITION 1.30a
 @set VERSION 1.30a
index 5f289e5866ebba9a1817db6a62ea4bb9733fcf61..2a4a4194fcffc7f29b035936779c730acba13f40 100644 (file)
@@ -1,4 +1,4 @@
-@set UPDATED 4 November 2001
+@set UPDATED 5 November 2001
 @set UPDATED-MONTH November 2001
 @set EDITION 1.30a
 @set VERSION 1.30a
 @set UPDATED-MONTH November 2001
 @set EDITION 1.30a
 @set VERSION 1.30a
index 4e84c77466fbb4c4a1fc4d54b5b61aa0d9ce5023..5cfa424bc7f871949e0d54c1b1b9a31d77d04886 100644 (file)
@@ -711,6 +711,13 @@ parse_union_decl (void)
 {
   int c;
   int count = 0;
 {
   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");
 
   if (typed)
     complain (_("multiple %s declarations"), "%union");
@@ -723,9 +730,9 @@ parse_union_decl (void)
   else
     obstack_1grow (&attrs_obstack, '\n');
 
   else
     obstack_1grow (&attrs_obstack, '\n');
 
-  obstack_sgrow (&attrs_obstack, "typedef union");
+  obstack_sgrow (&attrs_obstack, prologue);
   if (defines_flag)
   if (defines_flag)
-    obstack_sgrow (&defines_obstack, "typedef union");
+    obstack_sgrow (&defines_obstack, prologue);
 
   c = getc (finput);
 
 
   c = getc (finput);
 
@@ -760,9 +767,9 @@ parse_union_decl (void)
          count--;
          if (count <= 0)
            {
          count--;
          if (count <= 0)
            {
-             obstack_sgrow (&attrs_obstack, " YYSTYPE;\n");
+             obstack_sgrow (&attrs_obstack, epilogue);
              if (defines_flag)
              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 != ';')
              /* 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.  */
   /* 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\
   obstack_fgrow3 (&table_obstack, "\
 /* %s, made from %s\n\
    by GNU bison %s.  */\n\