Lemon update 2016-04-29 11:28:35 on branch trunk

— Lemon bug fix: Do not merge action routines unless their destructors are
also identical. Problem and suggested fix reported on the mailing list by
Kelvin Sherlock. (user: drh)
This commit is contained in:
Marisa Heit 2016-10-13 21:48:29 -05:00
parent de56be6c01
commit 45d441f103

View file

@ -3559,10 +3559,7 @@ PRIVATE int translate_code(struct lemon *lemp, struct rule *rp){
rp->line = rp->ruleline;
}
if( rp->lhsalias==0 ){
/* There is no LHS value symbol. */
lhsdirect = 1;
}else if( rp->nrhs==0 ){
if( rp->nrhs==0 ){
/* If there are no RHS symbols, then writing directly to the LHS is ok */
lhsdirect = 1;
}else if( rp->rhsalias[0]==0 ){
@ -3575,6 +3572,9 @@ PRIVATE int translate_code(struct lemon *lemp, struct rule *rp){
rp->rhs[0]->index,1-rp->nrhs,0);
rp->codePrefix = Strsafe(append_str(0,0,0,0,0));
}
}else if( rp->lhsalias==0 ){
/* There is no LHS value symbol. */
lhsdirect = 1;
}else if( strcmp(rp->lhsalias,rp->rhsalias[0])==0 ){
/* The LHS symbol and the left-most RHS symbol are the same, so
** direct writing is allowed */
@ -3717,7 +3717,7 @@ PRIVATE int translate_code(struct lemon *lemp, struct rule *rp){
/* Suffix code generation complete */
cp = append_str(0,0,0,0,0);
if( cp ) rp->codeSuffix = Strsafe(cp);
if( cp && cp[0] ) rp->codeSuffix = Strsafe(cp);
return rc;
}
@ -4399,7 +4399,14 @@ void ReportTable(
for(rp=lemp->rule; rp; rp=rp->next){
struct rule *rp2; /* Other rules with the same action */
if( rp->code==0 ) continue;
if( rp->code[0]=='\n' && rp->code[1]==0 ) continue; /* Will be default: */
if( rp->code[0]=='\n'
&& rp->code[1]==0
&& rp->codePrefix==0
&& rp->codeSuffix==0
){
/* No actions, so this will be part of the "default:" rule */
continue;
}
fprintf(out," case %d: /* ",rp->iRule);
writeRuleText(out, rp);
fprintf(out," */\n"); lineno++;
@ -4422,6 +4429,8 @@ void ReportTable(
for(rp=lemp->rule; rp; rp=rp->next){
if( rp->code==0 ) continue;
assert( rp->code[0]=='\n' && rp->code[1]==0 );
assert( rp->codePrefix==0 );
assert( rp->codeSuffix==0 );
fprintf(out," /* (%d) ", rp->iRule);
writeRuleText(out, rp);
fprintf(out," */ yytestcase(yyruleno==%d);\n", rp->iRule); lineno++;