bison-patches
[Top][All Lists]
Advanced

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

Re: Bison-2.1 grl :)


From: Paul Eggert
Subject: Re: Bison-2.1 grl :)
Date: Sun, 11 Sep 2005 22:56:03 -0700
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

address@hidden writes:

> for the new Bison-2.1:
> ++ no good solution for setjmp/longjmp found but
>    the macros can be defined already in bison-2.1 ?
> see http://lists.gnu.org/archive/html/bug-bison/2005-07/msg00014.html

Thanks for reminding me about that.  I installed the patch enclosed
below.

> ++ the file REFERENCES does not yet mention a theory reference
>    on the glr part. can that be added ?

It's in bison.texinfo.  Let's stop distributing REFERENCES;
it's wildly obsolete anyway.

> diff -aprNU5 glr.c glr.c.mine
> --- glr.c     2005-09-10 10:48:36.637893816 -1000
> +++ glr.c.mine        2005-09-10 11:05:56.944743136 -1000
> @@ -1666,10 +1666,12 @@ yyresolveValue (yySemanticOption* yyopti
>             break;
>           case 3:
>             yybest = yyp;
>             yymerge = yyfalse;
>             break;
> +         default: /* should not happen */
> +           break;

Hmm, I don't see the need for this.  The default case is impossible;
putting in "default: break;" might confuse readers.

> @@ -2083,10 +2085,11 @@ b4_syncline(address@hidden@], address@hidden@])])dnl
>      goto yyexhaustedlab;
>    switch (setjmp (yystack.yyexception_buffer))
>      {
>      case 1: goto yyabortlab;
>      case 2: goto yyexhaustedlab;
> +    default: break;
>      }

I suppose the user code might invoke longjmp itself and might return
the wrong value.  Sigh, perhaps this is worth checking for.  I
installed the patch enclosed below.

> [Bison-2.1 would be good for glr works. looks good.
>  the 99+ features later on? always liked Bison. :)
>  thanks for maintainer work. we know how difficult it is.]

You're welcome.  2.1 should be out soon....


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

        * Makefile.am (EXTRA_DIST): Do not distribute REFERENCES; it
        contains obsolete information and isn't worth distributing as a
        separate file anyway.
        * data/glr.c [defined YYSETJMP]: Don't include <setjmp.h>.
        (YYJMP_BUF, YYSETJMP, YYLONGJMP) [!defined YYSETJMP]: New macros.
        All uses of jmp_buf, setjmp, longjmp changed to use these instead.
        (yyparse): Abort if user code uses longjmp to throw an unexpected
        value.

--- Makefile.am 25 Jul 2005 06:45:32 -0000      1.39
+++ Makefile.am 12 Sep 2005 05:44:52 -0000
@@ -25,7 +25,7 @@ aclocaldir = @aclocaldir@
 aclocal_DATA = m4/bison-i18n.m4
 
 EXTRA_DIST = GNUmakefile Makefile.cfg Makefile.maint \
-  OChangeLog PACKAGING REFERENCES
+  OChangeLog PACKAGING
 
 .PHONY: maintainer-check
 maintainer-check:
--- data/glr.c  9 Sep 2005 22:59:46 -0000       1.119
+++ data/glr.c  12 Sep 2005 05:44:52 -0000
@@ -221,7 +221,6 @@ b4_syncline(address@hidden@], address@hidden@])
 #include <stdlib.h>
 #include <string.h>
 #include <stdarg.h>
-#include <setjmp.h>
 
 #ifndef YY_
 # if YYENABLE_NLS
@@ -255,6 +254,13 @@ b4_syncline(address@hidden@], address@hidden@])
 #define yytrue 1
 #define yyfalse 0
 
+#ifndef YYSETJMP
+# include <setjmp.h>
+# define YYJMP_BUF jmp_buf
+# define YYSETJMP(env) setjmp (env)
+# define YYLONGJMP(env, val) longjmp (env, val)
+#endif
+
 /*-----------------.
 | GCC extensions.  |
 `-----------------*/
@@ -728,7 +734,7 @@ struct yyGLRStack {
   int yyrawchar;
 ])[
   yySymbol* yytokenp;
-  jmp_buf yyexception_buffer;
+  YYJMP_BUF yyexception_buffer;
   yyGLRStackItem* yyitems;
   yyGLRStackItem* yynextFree;
   size_t yyspaceLeft;
@@ -746,7 +752,7 @@ yyFail (yyGLRStack* yystack]b4_pure_form
 {
   if (yymsg != NULL)
     yyerror (]b4_yyerror_args[yymsg);
-  longjmp (yystack->yyexception_buffer, 1);
+  YYLONGJMP (yystack->yyexception_buffer, 1);
 }
 
 static void yyMemoryExhausted (yyGLRStack* yystack)
@@ -754,7 +760,7 @@ static void yyMemoryExhausted (yyGLRStac
 static void
 yyMemoryExhausted (yyGLRStack* yystack)
 {
-  longjmp (yystack->yyexception_buffer, 2);
+  YYLONGJMP (yystack->yyexception_buffer, 2);
 }
 
 #if YYDEBUG || YYERROR_VERBOSE
@@ -2081,10 +2087,12 @@ b4_syncline(address@hidden@], address@hidden@])])dnl
 [
   if (! yyinitGLRStack (&yystack, YYINITDEPTH))
     goto yyexhaustedlab;
-  switch (setjmp (yystack.yyexception_buffer))
+  switch (YYSETJMP (yystack.yyexception_buffer))
     {
+    case 0: break;
     case 1: goto yyabortlab;
     case 2: goto yyexhaustedlab;
+    default: goto yybuglab;
     }
   yystack.yytokenp = &yytoken;
   yyglrShift (&yystack, 0, 0, 0, yylval, &yylloc);




reply via email to

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