bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

patches to get Bison 2.1 out the door


From: Paul Eggert
Subject: patches to get Bison 2.1 out the door
Date: Fri, 16 Sep 2005 16:11:08 -0700
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

I installed the following, mostly to get "make maintainer-check" to
work before Bison 2.1 went out.

2005-09-16  Paul Eggert  <address@hidden>

        * NEWS: Version 2.1.

        * NEWS: Remove notice of yytname change, since it was never in an
        official release.
        * data/glr.c (yydestroyGLRState): Rename local var to avoid shadowing
        diagnostic.
        * src/output.c (prepare): Likewise.
        * data/lalr1.cc (YYERROR_VERBOSE_IF): New macro.
        (yysyntax_error_): Use it to avoid GCC warning when YYERROR_VERBOSE
        is not defined.  This is an awful hack, but it's enough for now.
        All callers changed.
        * tests/glr-regression-at (make_value): Args are const pointers now,
        to avoid GCC warning.
        (Duplicated user destructor for lookahead): New test.  Currently
        skipped.  It fails on my host but I'm not sure it'll always fail.


Index: NEWS
===================================================================
RCS file: /cvsroot/bison/bison/NEWS,v
retrieving revision 1.122
diff -p -u -r1.122 NEWS
--- NEWS        15 Sep 2005 14:06:52 -0000      1.122
+++ NEWS        16 Sep 2005 22:53:06 -0000
@@ -1,7 +1,7 @@
 Bison News
 ----------
 
-Changes in version 2.0b, 2005-07-24:
+Changes in version 2.1, 2005-09-16:
 
 * Bison-generated parsers now support the translation of diagnostics like
   "syntax error" into languages other than English.  The default
@@ -18,11 +18,6 @@ Changes in version 2.0b, 2005-07-24:
 * Destructors are now called when the parser aborts, for all symbols left
   behind on the stack.  Also, the start symbol is now destroyed after a
   successful parse.  In both cases, the behavior was formerly inconsistent.
-
-* The yytname array now contains the same contents that it did in 2.0,
-  undoing an incompatible and undocumented change made in 2.0a.
-
-Changes in version 2.0a, 2005-05-22:
 
 * When generating verbose diagnostics, Bison-generated parsers no longer
   quote the literal strings associated with tokens.  For example, for
Index: configure.ac
===================================================================
RCS file: /cvsroot/bison/bison/configure.ac,v
retrieving revision 1.58
diff -p -u -r1.58 configure.ac
--- configure.ac        21 Aug 2005 22:39:21 -0000      1.58
+++ configure.ac        16 Sep 2005 22:53:06 -0000
@@ -23,7 +23,7 @@
 # least Autoconf 2.59.
 AC_PREREQ(2.59)
 
-AC_INIT([GNU Bison], [2.0c], address@hidden)
+AC_INIT([GNU Bison], [2.1], address@hidden)
 AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_MACRO_DIR([m4])
 
Index: data/glr.c
===================================================================
RCS file: /cvsroot/bison/bison/data/glr.c,v
retrieving revision 1.123
diff -p -u -r1.123 glr.c
--- data/glr.c  16 Sep 2005 19:03:54 -0000      1.123
+++ data/glr.c  16 Sep 2005 22:53:06 -0000
@@ -920,12 +920,12 @@ yydestroyGLRState (char const *yymsg, yy
       if (yys->yysemantics.yyfirstVal)
         {
           yySemanticOption *yyoption = yys->yysemantics.yyfirstVal;
-          yyGLRState *yyrhs;
+          yyGLRState *yyrh;
           int yyn;
-          for (yyrhs = yyoption->yystate, yyn = yyrhsLength (yyoption->yyrule);
+          for (yyrh = yyoption->yystate, yyn = yyrhsLength (yyoption->yyrule);
                yyn > 0;
-               yyrhs = yyrhs->yypred, yyn -= 1)
-            yydestroyGLRState (yymsg, yyrhs);
+               yyrh = yyrh->yypred, yyn -= 1)
+            yydestroyGLRState (yymsg, yyrh);
         }
     }
 }
Index: data/lalr1.cc
===================================================================
RCS file: /cvsroot/bison/bison/data/lalr1.cc,v
retrieving revision 1.98
diff -p -u -r1.98 lalr1.cc
--- data/lalr1.cc       16 Sep 2005 19:26:40 -0000      1.98
+++ data/lalr1.cc       16 Sep 2005 22:53:06 -0000
@@ -69,6 +69,12 @@ b4_syncline(address@hidden@], address@hidden@])[
 # define YYERROR_VERBOSE ]b4_error_verbose[
 #endif
 
+#if YYERROR_VERBOSE
+# define YYERROR_VERBOSE_IF(x) x
+#else
+# define YYERROR_VERBOSE_IF(x) /* empty */
+#endif
+
 /* Enabling the token table.  */
 #ifndef YYTOKEN_TABLE
 # define YYTOKEN_TABLE ]b4_token_table[
@@ -176,7 +182,7 @@ namespace yy
 
     /// Generate an error message.
     /// \param tok    the look-ahead token.
-    virtual std::string yysyntax_error_ (int tok);
+    virtual std::string yysyntax_error_ (YYERROR_VERBOSE_IF (int tok));
 
 #if YYDEBUG
     /// \brief Report a symbol on the debug stream.
@@ -695,7 +701,7 @@ yyerrlab:
   if (!yyerrstatus_)
     {
       ++yynerrs_;
-      error (yylloc, yysyntax_error_ (yyilooka));
+      error (yylloc, yysyntax_error_ (YYERROR_VERBOSE_IF (yyilooka)));
     }
 
   yyerror_range[0] = yylloc;
@@ -816,7 +822,7 @@ yyreturn:
 
 // Generate an error message.
 std::string
-yy::]b4_parser_class_name[::yysyntax_error_ (int tok)
+yy::]b4_parser_class_name[::yysyntax_error_ (YYERROR_VERBOSE_IF (int tok))
 {
   std::string res;
 #if YYERROR_VERBOSE
Index: src/output.c
===================================================================
RCS file: /cvsroot/bison/bison/src/output.c,v
retrieving revision 1.236
diff -p -u -r1.236 output.c
--- src/output.c        16 Sep 2005 19:26:39 -0000      1.236
+++ src/output.c        16 Sep 2005 22:53:06 -0000
@@ -618,8 +618,8 @@ prepare (void)
 
   /* About the skeletons. */
   {
-    char const* p = getenv ("BISON_PKGDATADIR");
-    MUSCLE_INSERT_STRING ("pkgdatadir", p ? p : PKGDATADIR);
+    char const *pkgdatadir = getenv ("BISON_PKGDATADIR");
+    MUSCLE_INSERT_STRING ("pkgdatadir", pkgdatadir ? pkgdatadir : PKGDATADIR);
     MUSCLE_INSERT_C_STRING ("skeleton", skeleton);
   }
 }
Index: tests/glr-regression.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/glr-regression.at,v
retrieving revision 1.16
diff -p -u -r1.16 glr-regression.at
--- tests/glr-regression.at     8 Sep 2005 18:41:46 -0000       1.16
+++ tests/glr-regression.at     16 Sep 2005 22:53:06 -0000
@@ -338,7 +338,8 @@ AT_CLEANUP
 AT_SETUP([Duplicate representation of merged trees])
 
 AT_DATA_GRAMMAR([glr-regr4.y],
-[[%union { char *ptr; }
+[[
+%union { char *ptr; }
 %type <ptr> S A A1 A2 B
 %glr-parser
 
@@ -347,7 +348,7 @@ AT_DATA_GRAMMAR([glr-regr4.y],
   #include <stdlib.h>
   #include <string.h>
   static char *merge (YYSTYPE, YYSTYPE);
-  static char *make_value (char *, char *);
+  static char *make_value (char const *, char const *);
   static void yyerror (char const *);
   static int yylex (void);
 %}
@@ -386,7 +387,7 @@ main (void)
 }
 
 static char *
-make_value (char *parent, char *child)
+make_value (char const *parent, char const *child)
 {
   char const format[] = "%s <- %s";
   char *value =
@@ -433,7 +434,8 @@ AT_CLEANUP
 AT_SETUP([User destructor for unresolved GLR semantic value])
 
 AT_DATA_GRAMMAR([glr-regr5.y],
-[[%{
+[[
+%{
   #include <stdio.h>
   #include <stdlib.h>
   static void yyerror (char const *);
@@ -503,7 +505,8 @@ AT_CLEANUP
 AT_SETUP([User destructor after an error during a split parse])
 
 AT_DATA_GRAMMAR([glr-regr6.y],
-[[%{
+[[
+%{
   #include <stdio.h>
   #include <stdlib.h>
   static void yyerror (char const *);
@@ -553,6 +556,83 @@ AT_CHECK([[./glr-regr6]], 0,
 [Destructor called.
 ],
 [syntax is ambiguous
+])
+
+AT_CLEANUP
+
+
+## ------------------------------------------------------------------------- ##
+## Duplicated user destructor for lookahead                                  ##
+## Thanks to Joel E. Denny for this test; see                                ##
+## <http://lists.gnu.org/archive/html/bison-patches/2005-08/msg00035.html>.  ##
+## ------------------------------------------------------------------------- ##
+
+AT_SETUP([Duplicated user destructor for lookahead])
+
+AT_DATA_GRAMMAR([glr-regr7.y],
+[[
+%{
+  #include <stdio.h>
+  #include <stdlib.h>
+  static void yyerror (char const *);
+  static int yylex (void);
+  #define YYSTACKEXPANDABLE 0
+%}
+
+%glr-parser
+%union { int *count; }
+%type <count> 'a'
+
+%destructor {
+  if ((*$$)++)
+    fprintf (stderr, "Destructor called on same value twice.\n");
+} 'a'
+
+%%
+
+start:
+    stack1 start
+  | stack2 start
+  | /* empty */
+  ;
+stack1: 'a' ;
+stack2: 'a' ;
+
+%%
+
+static int
+yylex (void)
+{
+  yylval.count = malloc (sizeof (int));
+  if (!yylval.count)
+    {
+      fprintf (stderr, "Test inconclusive.\n");
+      exit (EXIT_FAILURE);
+    }
+  *yylval.count = 0;
+  return 'a';
+}
+
+static void
+yyerror (char const *msg)
+{
+  fprintf (stderr, "%s\n", msg);
+}
+
+int
+main (void)
+{
+  return yyparse ();
+}
+]])
+
+AT_CHECK([[bison -o glr-regr7.c glr-regr7.y]], 0, [],
+[glr-regr7.y: conflicts: 2 reduce/reduce
+])
+AT_COMPILE([glr-regr7])
+
+AT_CHECK([[exit 77; ./glr-regr7]], 2, [],
+[memory exhausted
 ])
 
 AT_CLEANUP




reply via email to

[Prev in Thread] Current Thread [Next in Thread]