]> git.saurik.com Git - bison.git/blobdiff - data/glr.c
(symbol_user_token_number_set, symbol_make_alias, symbol_pack):
[bison.git] / data / glr.c
index aceec9d487aecbc10e02271994d4c7cd7fd6b76e..ef8d731ee0280bf46d50d54ee51cb75308393f9a 100644 (file)
@@ -146,7 +146,6 @@ b4_copyright([Skeleton parser for GLR parsing with Bison], [2002])
 [
 /* This is the parser code for GLR (Generalized LR) parser. */
 
-#include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -481,9 +480,9 @@ int yydebug;
 #else /* !YYDEBUG */
 
   /* Avoid empty `if' bodies.  */
-# define YYDPRINTF(Args)   {}
-# define YYDSYMPRINT(Args) {}
-# define YYDSYMPRINTF(Title, Token, Value, Location) {}
+# define YYDPRINTF(Args)
+# define YYDSYMPRINT(Args)
+# define YYDSYMPRINTF(Title, Token, Value, Location)
 
 #endif /* !YYDEBUG */
 
@@ -730,10 +729,10 @@ yydefaultAction (yyStateNum yystate)
   return yydefact[yystate];
 }
 
-#define yyis_table_ninf(yyindex) \
+#define yyis_table_ninf(yytable_value) \
   ]m4_if(m4_eval(b4_table_ninf < b4_table_min), 1,
         0,
-        ((yyindex) == YYTABLE_NINF))[
+        ((yytable_value) == YYTABLE_NINF))[
 
 /** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN.
  *  Result R means
@@ -753,7 +752,7 @@ yygetLRActions (yyStateNum yystate, int yytoken,
       *yyaction = -yydefact[yystate];
       *yyconflicts = yyconfl;
     }
-  else if (! yyis_table_ninf (yyindex))
+  else if (! yyis_table_ninf (yytable[yyindex]))
     {
       *yyaction = yytable[yyindex];
       *yyconflicts = yyconfl + yyconflp[yyindex];
@@ -790,14 +789,6 @@ yyisErrorAction (int yyaction)
 
                                /* GLRStates */
 
-/** True iff the semantic value of the edge leading to STATE is
- *  resolved. */
-static inline bool
-yyhasResolvedValue (yyGLRState* yystate)
-{
-  return yystate->yyresolved;
-}
-
 static void
 yyaddDeferredAction (yyGLRStack* yystack, yyGLRState* yystate,
                     yyGLRState* rhs, yyRuleNum yyrule]b4_pure_formals[)
@@ -967,14 +958,18 @@ yyremoveDeletes (yyGLRStack* yystack)
       if (yystack->yytops.yystates[yyi] == NULL)
        {
          if (yyi == yyj)
-           YYDPRINTF ((stderr, "Removing dead stacks.\n"));
+           {
+             YYDPRINTF ((stderr, "Removing dead stacks.\n"));
+           }
          yystack->yytops.yysize -= 1;
        }
       else
        {
          yystack->yytops.yystates[yyj] = yystack->yytops.yystates[yyi];
          if (yyj != yyi)
-           YYDPRINTF ((stderr, "Rename stack %d -> %d.\n", yyi, yyj));
+           {
+             YYDPRINTF ((stderr, "Rename stack %d -> %d.\n", yyi, yyj));
+           }
          yyj += 1;
        }
       yyi += 1;
@@ -1042,7 +1037,8 @@ yydoAction (yyGLRStack* yystack, int yyk, yyRuleNum yyrule,
     {
       /* Standard special case: single stack. */
       yyGLRStackItem* rhs = (yyGLRStackItem*) yystack->yytops.yystates[yyk];
-      assert (yyk == 0);
+      if (yyk != 0)
+       abort ();
       yystack->yynextFree -= yynrhs;
       yystack->yyspaceLeft += yynrhs;
       yystack->yytops.yystates[0] = & yystack->yynextFree[-1].yystate;
@@ -1067,7 +1063,8 @@ yydoAction (yyGLRStack* yystack, int yyk, yyRuleNum yyrule,
       for (yyi = yynrhs-1, yys = yystack->yytops.yystates[yyk]; 0 <= yyi;
           yyi -= 1, yys = yys->yypred)
        {
-         assert (yys->yypred != NULL);
+         if (! yys->yypred)
+           abort ();
          yyrhsVals[yyi].yystate.yyresolved = yytrue;
          yyrhsVals[yyi].yystate.yysemantics.yysval = yys->yysemantics.yysval;
          yyrhsVals[yyi].yystate.yyloc = yys->yyloc;
@@ -1155,7 +1152,8 @@ yyglrReduce (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule,
           0 < yyn; yyn -= 1)
        {
          yys = yys->yypred;
-         assert (yys != NULL);
+         if (! yys)
+           abort ();
        }
       yyupdateSplit (yystack, yys);
       yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
@@ -1192,7 +1190,8 @@ yysplitStack (yyGLRStack* yystack, int yyk)
 {
   if (yystack->yysplitPoint == NULL)
     {
-      assert (yyk == 0);
+      if (yyk != 0)
+       abort ();
       yystack->yysplitPoint = yystack->yytops.yystates[yyk];
     }
   if (yystack->yytops.yysize >= yystack->yytops.yycapacity)
@@ -1250,7 +1249,7 @@ yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1)
        yySemanticOption* yyz;
        for (yyz = yys0->yysemantics.yyfirstVal; yyz->yynext != NULL;
             yyz = yyz->yynext)
-         ;
+         continue;
        yyz->yynext = yys1->yysemantics.yyfirstVal;
       }
 }
@@ -1290,7 +1289,8 @@ yyresolveStates (yyGLRState* yys, int yyn, yyGLRStack* yystack]b4_user_formals[)
   YYRESULTTAG yyflag;
   if (0 < yyn)
     {
-      assert (yys->yypred != NULL);
+      if (! yys->yypred)
+       abort ();
       yyflag = yyresolveStates (yys->yypred, yyn-1, yystack]b4_user_args[);
       if (yyflag != yyok)
        return yyflag;
@@ -1320,7 +1320,8 @@ yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystack,
   for (yyi = yynrhs-1, yys = yyopt->yystate; 0 <= yyi;
        yyi -= 1, yys = yys->yypred)
     {
-      assert (yys->yypred != NULL);
+      if (! yys->yypred)
+       abort ();
       yyrhsVals[yyi].yystate.yyresolved = yytrue;
       yyrhsVals[yyi].yystate.yysemantics.yysval = yys->yysemantics.yysval;
       yyrhsVals[yyi].yystate.yyloc = yys->yyloc;
@@ -1460,7 +1461,7 @@ yyresolveStack (yyGLRStack* yystack]b4_user_formals[)
       for (yyn = 0, yys = yystack->yytops.yystates[0];
           yys != yystack->yysplitPoint;
           yys = yys->yypred, yyn += 1)
-       ;
+       continue;
       YYCHK (yyresolveStates (yystack->yytops.yystates[0], yyn, yystack
                             ]b4_user_args[));
     }
@@ -1512,7 +1513,8 @@ yyprocessOneStack (yyGLRStack* yystack, int yyk,
       yyStateNum yystate = yystack->yytops.yystates[yyk]->yylrState;
       YYDPRINTF ((stderr, "Stack %d Entering state %d\n", yyk, yystate));
 
-      assert (yystate != YYFINAL);
+      if (yystate == YYFINAL)
+       abort ();
       if (yyisDefaultedState (yystate))
        {
          yyrule = yydefaultAction (yystate);
@@ -1571,8 +1573,8 @@ yyprocessOneStack (yyGLRStack* yystack, int yyk,
 }
 
 static void
-yyreportParseError (yyGLRStack* yystack,
-                   YYSTYPE* yylvalp, YYLTYPE* yyllocp]b4_user_formals[)
+yyreportSyntaxError (yyGLRStack* yystack,
+                    YYSTYPE* yylvalp, YYLTYPE* yyllocp]b4_user_formals[)
 {
   /* `Unused' warnings. */
   (void) yylvalp;
@@ -1630,8 +1632,8 @@ yyreportParseError (yyGLRStack* yystack,
    YYLVALP, and YYLLOCP point to the syntactic category, semantic
    value, and location of the lookahead.  */
 static void
-yyrecoverParseError (yyGLRStack* yystack,
-                    YYSTYPE* yylvalp, YYLTYPE* yyllocp]b4_user_formals[)
+yyrecoverSyntaxError (yyGLRStack* yystack,
+                     YYSTYPE* yylvalp, YYLTYPE* yyllocp]b4_user_formals[)
 {
   yySymbol* const yytokenp = yystack->yytokenp;
   size_t yyk;
@@ -1796,7 +1798,7 @@ yyrecoverParseError (yyGLRStack* yystack,
              yyrule = yydefaultAction (yystate);
              if (yyrule == 0)
                {
-                 yyreportParseError (&yystack, yylvalp, yyllocp]b4_user_args[);
+                 yyreportSyntaxError (&yystack, yylvalp, yyllocp]b4_user_args[);
                  goto yyuser_error;
                }
              YYCHK1 (yyglrReduce (&yystack, 0, yyrule, yytrue]b4_lpure_args[));
@@ -1827,7 +1829,7 @@ yyrecoverParseError (yyGLRStack* yystack,
                }
              else if (yyisErrorAction (yyaction))
                {
-                 yyreportParseError (&yystack, yylvalp, yyllocp]b4_user_args[);
+                 yyreportSyntaxError (&yystack, yylvalp, yyllocp]b4_user_args[);
                  goto yyuser_error;
                }
              else
@@ -1852,7 +1854,7 @@ yyrecoverParseError (yyGLRStack* yystack,
                yyFail (&yystack][]b4_lpure_args[, "syntax error");
              YYCHK1 (yyresolveStack (&yystack]b4_user_args[));
              YYDPRINTF ((stderr, "Returning to deterministic operation.\n"));
-             yyreportParseError (&yystack, yylvalp, yyllocp]b4_user_args[);
+             yyreportSyntaxError (&yystack, yylvalp, yyllocp]b4_user_args[);
              goto yyuser_error;
            }
          else if (yystack.yytops.yysize == 1)
@@ -1865,7 +1867,7 @@ yyrecoverParseError (yyGLRStack* yystack,
        }
       continue;
     yyuser_error:
-      yyrecoverParseError (&yystack, yylvalp, yyllocp]b4_user_args[);
+      yyrecoverSyntaxError (&yystack, yylvalp, yyllocp]b4_user_args[);
       yyposn = yystack.yytops.yystates[0]->yyposn;
     }
  yyDone: