bison-patches
[Top][All Lists]
Advanced

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

Re: calc.at workaround for current test failures


From: Paul Eggert
Subject: Re: calc.at workaround for current test failures
Date: 25 Jul 2003 00:04:28 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Frank Heckenbach <address@hidden> writes:

> I hope the following patch for YY_ABORT meets the requirements.

On further thought, why not use the model of 'assert' rather than
'abort'?  That way, the user can easily use either assert or abort,
depending on user preferences.  The default would be to use abort,
as now.

Here's a proposed patch to do it that way:

2003-07-25  Paul Eggert  <address@hidden>

        * data/glr.c (YYASSERT): New macro.
        (yyfillin, yydoAction, yyglrReduce, yysplitStack,
        yyresolveStates, yyprocessOneStack):
        Use `YYASSERT (FOO);' rather than `if (! (FOO)) abort ();'.

Index: glr.c
===================================================================
RCS file: /cvsroot/bison/bison/data/glr.c,v
retrieving revision 1.60
diff -p -u -r1.60 glr.c
--- glr.c       20 Jun 2003 22:52:12 -0000      1.60
+++ glr.c       25 Jul 2003 06:57:58 -0000
@@ -239,6 +239,10 @@ b4_syncline(address@hidden@], address@hidden@])
 # endif
 #endif
 
+#ifndef YYASSERT
+# define YYASSERT(condition) ((void) ((condition) || (abort (), 0)))
+#endif
+
 #ifndef ATTRIBUTE_UNUSED
 # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
 #endif
@@ -639,8 +643,7 @@ yyfillin (yyGLRStackItem *yyvsp, int yyl
   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;
@@ -1089,8 +1092,7 @@ yydoAction (yyGLRStack* yystack, int yyk
     {
       /* 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;
@@ -1107,8 +1109,7 @@ yydoAction (yyGLRStack* yystack, int yyk
       for (yyi = 0; yyi < yynrhs; yyi += 1)
        {
          yys = yys->yypred;
-         if (yys == NULL)
-           abort ();
+         YYASSERT (yys);
        }
       yyupdateSplit (yystack, yys);
       yystack->yytops.yystates[yyk] = yys;
@@ -1184,8 +1185,7 @@ yyglrReduce (yyGLRStack* yystack, size_t
           0 < yyn; yyn -= 1)
        {
          yys = yys->yypred;
-         if (yys == NULL)
-           abort ();
+         YYASSERT (yys);
        }
       yyupdateSplit (yystack, yys);
       yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
@@ -1223,8 +1223,7 @@ yysplitStack (yyGLRStack* yystack, int y
 {
   if (yystack->yysplitPoint == NULL)
     {
-      if (yyk != 0)
-       abort ();
+      YYASSERT (yyk == 0);
       yystack->yysplitPoint = yystack->yytops.yystates[yyk];
     }
   if (yystack->yytops.yysize >= yystack->yytops.yycapacity)
@@ -1322,8 +1321,7 @@ yyresolveStates (yyGLRState* yys, int yy
   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;
@@ -1540,8 +1538,8 @@ yyprocessOneStack (yyGLRStack* yystack, 
       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);




reply via email to

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