Fix a bug in lemon that leads to an assertion fault given an invalid
grammar. The bug and this fix do not effect on SQLite. Ticket #2107. (CVS 3528)
FossilOrigin-Name: f2ad230f6dce98d664370d77845b5f585de20f08
diff --git a/tool/lemon.c b/tool/lemon.c
index 2dd2a46..dbb00c1 100644
--- a/tool/lemon.c
+++ b/tool/lemon.c
@@ -361,8 +361,6 @@
rc = ap1->sp->index - ap2->sp->index;
if( rc==0 ) rc = (int)ap1->type - (int)ap2->type;
if( rc==0 ){
- assert( ap1->type==REDUCE || ap1->type==RD_RESOLVED || ap1->type==CONFLICT);
- assert( ap2->type==REDUCE || ap2->type==RD_RESOLVED || ap2->type==CONFLICT);
rc = ap1->x.rp->index - ap2->x.rp->index;
}
return rc;
@@ -1019,6 +1017,10 @@
struct symbol *spx, *spy;
int errcnt = 0;
assert( apx->sp==apy->sp ); /* Otherwise there would be no conflict */
+ if( apx->type==SHIFT && apy->type==SHIFT ){
+ apy->type = CONFLICT;
+ errcnt++;
+ }
if( apx->type==SHIFT && apy->type==REDUCE ){
spx = apx->sp;
spy = apy->x.rp->precsym;