]> git.saurik.com Git - bison.git/blobdiff - data/glr.c
* examples/calc++/test: Use set -x only when VERBOSE.
[bison.git] / data / glr.c
index 37e05af7fa6975cccef60c07f994638e2641734e..877e400960ac69f36396dc32a89a3f0415938527 100644 (file)
@@ -154,7 +154,7 @@ m4_if(b4_prefix[], [yy], [],
 #define yynerrs b4_prefix[]nerrs
 #define yylloc b4_prefix[]lloc])
 
-b4_token_defines(b4_tokens)
+b4_token_enums(b4_tokens)
 
 /* Copy the first part of user declarations.  */
 b4_pre_prologue[
@@ -221,7 +221,6 @@ b4_syncline([@oline@], [@ofile@])
 #include <stdlib.h>
 #include <string.h>
 #include <stdarg.h>
-#include <setjmp.h>
 
 #ifndef YY_
 # if YYENABLE_NLS
@@ -235,6 +234,9 @@ b4_syncline([@oline@], [@ofile@])
 # endif
 #endif
 
+/* Suppress unused-variable warnings by "using" E.  */
+#define YYUSE(e) do {;} while (/*CONSTCOND*/ yyfalse && (e))
+
 #ifndef YYFREE
 # define YYFREE free
 #endif
@@ -255,6 +257,13 @@ b4_syncline([@oline@], [@ofile@])
 #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.  |
 `-----------------*/
@@ -464,7 +473,7 @@ static const ]b4_int_type_for([b4_stos])[ yystos[] =
          (Current).first_column = (Current).last_column =              \
            YYRHSLOC (Rhs, 0).last_column;                              \
        }                                                               \
-    while (0)
+    while (/*CONSTCOND*/ 0)
 
 /* YY_LOCATION_PRINT -- Print the location on the stream.
    This macro was not mandated originally: define only if we know
@@ -509,7 +518,7 @@ typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
 
 #define YYCHK(YYE)                                                          \
    do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; }      \
-   while (0)
+   while (/*CONSTCOND*/ 0)
 
 #if YYDEBUG
 
@@ -521,7 +530,7 @@ typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
 do {                                           \
   if (yydebug)                                 \
     YYFPRINTF Args;                            \
-} while (0)
+} while (/*CONSTCOND*/ 0)
 
 ]b4_yysymprint_generate([b4_c_ansi_function_def])[
 
@@ -534,7 +543,7 @@ do {                                                                \
                   Type, Value]b4_location_if([, Location])[);  \
       YYFPRINTF (stderr, "\n");                                        \
     }                                                          \
-} while (0)
+} while (/*CONSTCOND*/ 0)
 
 /* Nonzero means print parse trace.  It is left uninitialized so that
    multiple parsers can coexist.  */
@@ -728,7 +737,7 @@ struct yyGLRStack {
   int yyrawchar;
 ])[
   yySymbol* yytokenp;
-  jmp_buf yyexception_buffer;
+  YYJMP_BUF yyexception_buffer;
   yyGLRStackItem* yyitems;
   yyGLRStackItem* yynextFree;
   size_t yyspaceLeft;
@@ -746,7 +755,7 @@ yyFail (yyGLRStack* yystack]b4_pure_formals[, const char* yymsg)
 {
   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 +763,7 @@ static void yyMemoryExhausted (yyGLRStack* yystack)
 static void
 yyMemoryExhausted (yyGLRStack* yystack)
 {
-  longjmp (yystack->yyexception_buffer, 2);
+  YYLONGJMP (yystack->yyexception_buffer, 2);
 }
 
 #if YYDEBUG || YYERROR_VERBOSE
@@ -871,9 +880,8 @@ b4_syncline([@oline@], [@ofile@])
 static void
 yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1)
 {
-  /* `Use' the arguments.  */
-  (void) yy0;
-  (void) yy1;
+  YYUSE (yy0);
+  YYUSE (yy1);
 
   switch (yyn)
     {
@@ -914,12 +922,12 @@ yydestroyGLRState (char const *yymsg, yyGLRState *yys)
       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);
         }
     }
 }
@@ -1300,7 +1308,7 @@ yydoAction (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule,
 do {                                   \
   if (yydebug)                         \
     yy_reduce_print (K, Rule);         \
-} while (0)
+} while (/*CONSTCOND*/ 0)
 
 /*----------------------------------------------------------.
 | Report that the RULE is going to be reduced on stack #K.  |
@@ -1615,9 +1623,8 @@ static void
 yyreportAmbiguity (yySemanticOption* yyx0, yySemanticOption* yyx1,
                   yyGLRStack* yystack]b4_pure_formals[)
 {
-  /* `Unused' warnings.  */
-  (void) yyx0;
-  (void) yyx1;
+  YYUSE (yyx0);
+  YYUSE (yyx1);
 
 #if YYDEBUG
   YYFPRINTF (stderr, "Ambiguity detected.\n");
@@ -1668,6 +1675,11 @@ yyresolveValue (yySemanticOption* yyoptionList, yyGLRStack* yystack,
              yybest = yyp;
              yymerge = yyfalse;
              break;
+           default:
+             /* This cannot happen so it is not worth a YYASSERT (yyfalse),
+                but some compilers complain if the default case is
+                omitted.  */
+             break;
            }
          yypp = &yyp->yynext;
        }
@@ -1825,9 +1837,8 @@ static void
 yyreportSyntaxError (yyGLRStack* yystack,
                     YYSTYPE* yylvalp, YYLTYPE* yyllocp]b4_user_formals[)
 {
-  /* `Unused' warnings. */
-  (void) yylvalp;
-  (void) yyllocp;
+  YYUSE (yylvalp);
+  YYUSE (yyllocp);
 
   if (yystack->yyerrState == 0)
     {
@@ -2035,7 +2046,7 @@ yyrecoverSyntaxError (yyGLRStack* yystack,
     default:                                                                \
       goto yybuglab;                                                        \
     }                                                                       \
-  } while (0)
+  } while (/*CONSTCOND*/ 0)
 
 
 /*----------.
@@ -2081,10 +2092,12 @@ b4_syncline([@oline@], [@ofile@])])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);
@@ -2308,7 +2321,7 @@ m4_if(b4_defines_flag, 0, [],
 b4_copyright([Skeleton parser for GLR parsing with Bison],
   [2002, 2003, 2004, 2005])
 
-b4_token_defines(b4_tokens)
+b4_token_enums(b4_tokens)
 
 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
 m4_ifdef([b4_stype],