[Top][All Lists]

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

Re: assert failure at line 1896

From: Joel E. Denny
Subject: Re: assert failure at line 1896
Date: Sun, 21 May 2006 02:22:27 -0400 (EDT)

On Sat, 20 May 2006, Joel E. Denny wrote:

> The YYASSERT (the only one in yyresolveLocations) is bogus.  Just remove 
> it from your Bison installation.

Groan.  There are actually two YYASSERT's there, and I meant the second 
one.  It seems I can't be trusted today, but I installed the following 
patch anyway.


2006-05-21  Joel E. Denny  <address@hidden>

        * data/glr.c (yyresolveLocations): Remove bogus YYASSERT that the
        state before an empty RHS is always resolved here.  Only the location
        of that state is guaranteed to be resolved, and that's enough.  This
        fixes the remaining bug reported by Derek M. Jones in
        * tests/glr-regression.at (Uninitialized location when reporting
        ambiguity): Test the above case.
        Also, the embedded comments in this test case claim it checks the case
        of an empty RHS that has inherited the initial location.  However, the
        corresponding LHS was already resolved, so yyresolveLocations didn't
        actually have reason to modify it.  Fix this by forcing
        nondeterministic operation at the beginning of the parse.

Index: data/glr.c
RCS file: /sources/bison/bison/data/glr.c,v
retrieving revision 1.175
diff -p -u -r1.175 glr.c
--- data/glr.c  17 May 2006 16:39:40 -0000      1.175
+++ data/glr.c  21 May 2006 05:51:16 -0000
@@ -201,7 +201,7 @@ typedef struct YYLTYPE
 b4_defines_if([#include @address@hidden,
-              [b4_shared_declarations])[
+             [b4_shared_declarations])[
 /* Enabling traces.  */
 #ifndef YYDEBUG
@@ -1836,8 +1836,14 @@ yyresolveLocations (yyGLRState* yys1, in
+             /* Both yyresolveAction and yyresolveLocations traverse the GSS
+                in reverse rightmost order.  It is only necessary to invoke
+                yyresolveLocations on a subforest for which yyresolveAction
+                would have been invoked next had an ambiguity not been
+                detected.  Thus the location of the previous state (but not
+                necessarily the previous state itself) is guaranteed to be
+                resolved already.  */
              yyGLRState *yyprevious = yyoption->yystate;
-             YYASSERT (yyprevious->yyresolved);
              yyrhsloc[0].yystate.yyloc = yyprevious->yyloc;
          yychar_current = yychar;
Index: tests/glr-regression.at
RCS file: /sources/bison/bison/tests/glr-regression.at,v
retrieving revision 1.34
diff -p -u -r1.34 glr-regression.at
--- tests/glr-regression.at     7 Mar 2006 06:42:23 -0000       1.34
+++ tests/glr-regression.at     21 May 2006 05:51:17 -0000
@@ -1606,17 +1606,22 @@ AT_DATA_GRAMMAR([glr-regr17.y],
+/* Tests the case of an empty RHS that has inherited the location of the
+   previous nonterminal, which is unresolved.  That location is reported as the
+   last position of the ambiguity.  */
+start: ambig1 empty1 | ambig2 empty2 ;
 /* Tests multiple levels of yyresolveLocations recursion.  */
-start: ambig1 | ambig2 ;
 ambig1: sub_ambig1 | sub_ambig2 ;
 ambig2: sub_ambig1 | sub_ambig2 ;
-/* Tests non-empty RHS as well as empty RHS with either initial location or
-   location of previous token.  Both empty RHS locations are printed in the
-   error message.  */
-sub_ambig1: empty 'a' 'b' empty ;
-sub_ambig2: empty 'a' 'b' empty ;
-empty: ;
+/* Tests the case of a non-empty RHS as well as the case of an empty RHS that
+   has inherited the initial location.  The empty RHS's location is reported as
+   the first position in the ambiguity.  */
+sub_ambig1: empty1 'a' 'b' ;
+sub_ambig2: empty2 'a' 'b' ;
+empty1: ;
+empty2: ;

reply via email to

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