From 2e55b04da45c2fb17a0464f0480af33082c23810 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 30 Apr 2016 17:19:30 +0000 Subject: [PATCH] More bug fixes to Lemon identified by Kelvin Sherlock. None of these have any impact on SQLite. FossilOrigin-Name: 762bdc55f8878ee2ef65af2165a8e7fdbddf0160 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/lemon.c | 23 ++++++++++++++++------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index c3be714871..c82cd48e76 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplifications\sto\sthe\sOP_Halt\sopcode\simplementation. -D 2016-04-30T02:59:15.737 +C More\sbug\sfixes\sto\sLemon\sidentified\sby\sKelvin\sSherlock.\s\sNone\sof\sthese\nhave\sany\simpact\son\sSQLite. +D 2016-04-30T17:19:30.162 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -1416,7 +1416,7 @@ F tool/fuzzershell.c 94019b185caceffc9f7c7b678a6489e42bc2aefa F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce -F tool/lemon.c 83318dff3911e47f2b85e136e56aa1c4674a2d2b +F tool/lemon.c f38a55106d79b7a4c063abb958517d6c47dc6ac7 F tool/lempar.c 404ea3dc27dbeed343f0e61b1d36e97b9f5f0fb6 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1486,7 +1486,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 614bb709d34e11488da88861243023cc5de4b409 -R b15a9da5ab52f0ada1f3249ae1287c3e +P daf4630f96f13133664908045e279da9d5a40bb5 +R abf1ac3c7e03f177ba74945ccc38d922 U drh -Z 574106fd28e4252d413254df9dee5be2 +Z cfd7bc89828187e9540e8e1e6f984687 diff --git a/manifest.uuid b/manifest.uuid index 5bb7f4d874..03d710e202 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -daf4630f96f13133664908045e279da9d5a40bb5 \ No newline at end of file +762bdc55f8878ee2ef65af2165a8e7fdbddf0160 \ No newline at end of file diff --git a/tool/lemon.c b/tool/lemon.c index 2f76465d89..01c8a1da96 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -3556,14 +3556,11 @@ PRIVATE int translate_code(struct lemon *lemp, struct rule *rp){ } - 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 ){ - /* The left-most RHS symbol has not value. LHS direct is ok. But + /* The left-most RHS symbol has no value. LHS direct is ok. But ** we have to call the distructor on the RHS symbol first. */ lhsdirect = 1; if( has_destructor(rp->rhs[0],lemp) ){ @@ -3572,6 +3569,9 @@ PRIVATE int translate_code(struct lemon *lemp, struct rule *rp){ rp->rhs[0]->index,1-rp->nrhs); rp->codePrefix = Strsafe(append_str(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 */ @@ -3715,7 +3715,7 @@ PRIVATE int translate_code(struct lemon *lemp, struct rule *rp){ /* Suffix code generation complete */ cp = append_str(0,0,0,0); - if( cp ) rp->codeSuffix = Strsafe(cp); + if( cp && cp[0] ) rp->codeSuffix = Strsafe(cp); return rc; } @@ -4397,7 +4397,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++; @@ -4420,6 +4427,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++;