X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/a525b5687de5db1793c64489f3e372e3f82d9664..0cc3da3a4e993080b69ee94156c280b5f2630013:/data/glr.c?ds=sidebyside diff --git a/data/glr.c b/data/glr.c index eebea9d7..f2173854 100644 --- a/data/glr.c +++ b/data/glr.c @@ -111,7 +111,7 @@ m4_define([b4_lhs_value], # Expansion of $NUM, where the current rule has RULE-LENGTH # symbols on RHS. m4_define([b4_rhs_value], -[yyvsp@{YYFILL (m4_eval([$2 - $1]))@}.yystate.yysemantics.yysval[]m4_ifval([$3], [.$3])]) +[((yyGLRStackItem const *)yyvsp)@{YYFILL (m4_eval([$2 - $1]))@}.yystate.yysemantics.yysval[]m4_ifval([$3], [.$3])]) @@ -131,7 +131,7 @@ m4_define([b4_lhs_location], # Expansion of @NUM, where the current rule has RULE-LENGTH symbols # on RHS. m4_define([b4_rhs_location], -[yyvsp@{YYFILL (m4_eval([$2 - $1]))@}.yystate.yyloc]) +[((yyGLRStackItem const *)yyvsp)@{YYFILL (m4_eval([$2 - $1]))@}.yystate.yyloc]) # We do want M4 expansion after # for CPP macros. m4_changecom() @@ -249,6 +249,10 @@ b4_syncline([@oline@], [@ofile@]) # endif #endif +#ifndef YYASSERT +# define YYASSERT(condition) ((void) ((condition) || (abort (), 0))) +#endif + #ifndef ATTRIBUTE_UNUSED # define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) #endif @@ -649,8 +653,7 @@ yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1) s = yyvsp[yylow0].yystate.yypred; for (i = yylow0-1; i >= yylow1; i -= 1) { - if (! s->yyresolved) - abort (); + YYASSERT (s->yyresolved); yyvsp[i].yystate.yyresolved = yytrue; yyvsp[i].yystate.yysemantics.yysval = s->yysemantics.yysval; yyvsp[i].yystate.yyloc = s->yyloc; @@ -737,10 +740,9 @@ b4_syncline([@oline@], [@ofile@]) } -static YYSTYPE +static void yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1) { - YYSTYPE yyval = *yy0; /* `Use' the arguments. */ (void) yy0; (void) yy1; @@ -749,7 +751,6 @@ yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1) { b4_mergers } - return yyval; } [ /* Bison grammar-table manipulation. */ @@ -1099,8 +1100,7 @@ yydoAction (yyGLRStack* yystack, int yyk, yyRuleNum yyrule, { /* Standard special case: single stack. */ yyGLRStackItem* rhs = (yyGLRStackItem*) yystack->yytops.yystates[yyk]; - if (yyk != 0) - abort (); + YYASSERT (yyk == 0); yystack->yynextFree -= yynrhs; yystack->yyspaceLeft += yynrhs; yystack->yytops.yystates[0] = & yystack->yynextFree[-1].yystate; @@ -1117,8 +1117,7 @@ yydoAction (yyGLRStack* yystack, int yyk, yyRuleNum yyrule, for (yyi = 0; yyi < yynrhs; yyi += 1) { yys = yys->yypred; - if (yys == NULL) - abort (); + YYASSERT (yys); } yyupdateSplit (yystack, yys); yystack->yytops.yystates[yyk] = yys; @@ -1194,14 +1193,12 @@ yyglrReduce (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule, 0 < yyn; yyn -= 1) { yys = yys->yypred; - if (yys == NULL) - abort (); + YYASSERT (yys); } yyupdateSplit (yystack, yys); yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule)); YYDPRINTF ((stderr, - "Reduced stack %lu by rule #%d; action deferred. " - "Now in state %d.\n", + "Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n", (unsigned long int) yyk, yyrule - 1, yynewLRState)); for (yyi = 0; yyi < yystack->yytops.yysize; yyi += 1) if (yyi != yyk && yystack->yytops.yystates[yyi] != NULL) @@ -1233,8 +1230,7 @@ yysplitStack (yyGLRStack* yystack, int yyk) { if (yystack->yysplitPoint == NULL) { - if (yyk != 0) - abort (); + YYASSERT (yyk == 0); yystack->yysplitPoint = yystack->yytops.yystates[yyk]; } if (yystack->yytops.yysize >= yystack->yytops.yycapacity) @@ -1332,8 +1328,7 @@ yyresolveStates (yyGLRState* yys, int yyn, yyGLRStack* yystack]b4_user_formals[) YYRESULTTAG yyflag; if (0 < yyn) { - if (yys->yypred == NULL) - abort (); + YYASSERT (yys->yypred); yyflag = yyresolveStates (yys->yypred, yyn-1, yystack]b4_user_args[); if (yyflag != yyok) return yyflag; @@ -1478,7 +1473,7 @@ yyresolveValue (yySemanticOption* yyoptionList, yyGLRStack* yystack, YYSTYPE yyval1; YYLTYPE yydummy; YYCHK (yyresolveAction (yyp, yystack, &yyval1, &yydummy]b4_user_args[)); - *yyvalp = yyuserMerge (yymerger[yyp->yyrule], yyvalp, &yyval1); + yyuserMerge (yymerger[yyp->yyrule], yyvalp, &yyval1); } } return yyok; @@ -1550,8 +1545,8 @@ yyprocessOneStack (yyGLRStack* yystack, int yyk, yyStateNum yystate = yystack->yytops.yystates[yyk]->yylrState; YYDPRINTF ((stderr, "Stack %d Entering state %d\n", yyk, yystate)); - if (yystate == YYFINAL) - abort (); + YYASSERT (yystate != YYFINAL); + if (yyisDefaultedState (yystate)) { yyrule = yydefaultAction (yystate);