-C Code\sto\simplement\sCREATE\sVIEW\sis\sin\splace.\s\sA\squick\ssmoke\stest\sshows\sthat\nit\sworks,\sbut\sthere\sare\sprobably\sstill\smany\sbugs.\s(CVS\s387)
-D 2002-02-23T02:32:10
+C Bug\sfix\sin\slemon:\s3-way\sconflicts\s(SHIFT/REDUCE/REDUCE)\swere\snot\sdetected\sor\nresolved.\s\sThis\sis\snow\sfixed.\s\sAlso,\stable\scompression\sworks\sa\slittle\sbetter.\s(CVS\s388)
+D 2002-02-23T18:45:13
F Makefile.in 9fa4277413bf1d9cf91365f07d4108d7d87ed2af
F Makefile.template 3372d45f8853afdb70bd30cc6fb50a3cd9069834
F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
F test/update.test 3cf1ca0565f678063c2dfa9a7948d2d66ae1a778
F test/vacuum.test 8acf8669f3b627e54149b25165b034aa06c2432e
F test/where.test 032d581c3de4893eba33b569e581c46b941bb02a
-F tool/lemon.c bfd036ab9309c7f34e1357d9a065ad137814e741
+F tool/lemon.c 7502222a5d704d9d5d1ac437f73667855d687862
F tool/lempar.c 9b604e6a8b3d55c0b9cbcb130a7302fb8bafe2b9
F tool/memleak.awk 296dfbce7a9ca499b95ce04e30334e64a50052e0
F tool/opNames.awk 5ba1f48aa854ee3b7c3d2b54233665bc3e649ea2
F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279
F www/tclsqlite.tcl 829b393d1ab187fd7a5e978631b3429318885c49
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P b2a9807fed544e83002366149b9a363759338c5d
-R e0b567ef590e442398fe19c801c19dbc
+P 39fed2df11382b9855d518502a6c2ca200fa66b8
+R bbf759a9eca350d9e39199c34c6ab1fb
U drh
-Z 84f7f5c8e0889cae09918887440ad98b
+Z 95f9230334dd6740861a9a25c1c709f1
stp = lemp->sorted[i];
assert( stp->ap );
stp->ap = Action_sort(stp->ap);
- for(ap=stp->ap; ap && ap->next; ap=nap){
+ for(ap=stp->ap; ap && ap->next; ap=ap->next){
for(nap=ap->next; nap && nap->sp==ap->sp; nap=nap->next){
/* The two actions "ap" and "nap" have the same lookahead.
** Figure out which one should be used */
apx->type = RD_RESOLVED;
}
}else{
- /* Can't happen. Shifts have to come before Reduces on the
- ** list because the reduces were added last. Hence, if apx->type==REDUCE
- ** then it is impossible for apy->type==SHIFT */
+ assert(
+ apx->type==SH_RESOLVED ||
+ apx->type==RD_RESOLVED ||
+ apx->type==CONFLICT ||
+ apy->type==SH_RESOLVED ||
+ apy->type==RD_RESOLVED ||
+ apy->type==CONFLICT
+ );
+ /* The REDUCE/SHIFT case cannot happen because SHIFTs come before
+ ** REDUCEs on the list. If we reach this point it must be because
+ ** the parser conflict had already been resolved. */
}
return errcnt;
}
/* Reduce the size of the action tables, if possible, by making use
** of defaults.
**
-** In this version, if all REDUCE actions use the same rule, make
-** them the default. Only default them if there are more than one.
+** In this version, we take the most frequent REDUCE action and make
+** it the default. Only default a reduce if there are more than one.
*/
void CompressTables(lemp)
struct lemon *lemp;
{
struct state *stp;
- struct action *ap;
- struct rule *rp;
+ struct action *ap, *ap2;
+ struct rule *rp, *rp2, *rbest;
+ int nbest, n;
int i;
int cnt;
for(i=0; i<lemp->nstate; i++){
stp = lemp->sorted[i];
+ nbest = 0;
+ rbest = 0;
- /* Find the first REDUCE action */
- for(ap=stp->ap; ap && ap->type!=REDUCE; ap=ap->next);
- if( ap==0 ) continue;
-
- /* Remember the rule used */
- rp = ap->x.rp;
-
- /* See if all other REDUCE acitons use the same rule */
- cnt = 1;
- for(ap=ap->next; ap; ap=ap->next){
- if( ap->type==REDUCE ){
- if( ap->x.rp!=rp ) break;
- cnt++;
+ for(ap=stp->ap; ap; ap=ap->next){
+ if( ap->type!=REDUCE ) continue;
+ rp = ap->x.rp;
+ if( rp==rbest ) continue;
+ n = 1;
+ for(ap2=ap->next; ap2; ap2=ap2->next){
+ if( ap2->type!=REDUCE ) continue;
+ rp2 = ap2->x.rp;
+ if( rp2==rbest ) continue;
+ if( rp2==rp ) n++;
+ }
+ if( n>nbest ){
+ nbest = n;
+ rbest = rp;
}
}
- if( ap || cnt==1 ) continue;
+
+ /* Do not make a default if the number of rules to default
+ ** is not at least 2 */
+ if( nbest<2 ) continue;
+
- /* Combine all REDUCE actions into a single default */
- for(ap=stp->ap; ap && ap->type!=REDUCE; ap=ap->next);
+ /* Combine matching REDUCE actions into a single default */
+ for(ap=stp->ap; ap; ap=ap->next){
+ if( ap->type==REDUCE && ap->x.rp==rbest ) break;
+ }
assert( ap );
ap->sp = Symbol_new("{default}");
for(ap=ap->next; ap; ap=ap->next){
- if( ap->type==REDUCE ) ap->type = NOT_USED;
+ if( ap->type==REDUCE && ap->x.rp==rbest ) ap->type = NOT_USED;
}
stp->ap = Action_sort(stp->ap);
}
}
+
/***************** From the file "set.c" ************************************/
/*
** Set manipulation routines for the LEMON parser generator.