]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Enhance Lemon and the parser template so that it can once again build parsers
authordrh <drh@noemail.net>
Tue, 24 May 2016 18:55:08 +0000 (18:55 +0000)
committerdrh <drh@noemail.net>
Tue, 24 May 2016 18:55:08 +0000 (18:55 +0000)
that have no unreachable branches.

FossilOrigin-Name: 41fd46e2962ba9a1e1f6867567499d1f6f5b8372

manifest
manifest.uuid
tool/lemon.c
tool/lempar.c

index 8b597e7bf2ad6031f2e1104a7f54a349d619ea8c..a229ea4a91d9af7144424e1c86e60650d3d8e641 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Minor\schange\sto\sthe\swalcrash4.test\smodule\sso\sthat\sit\sworks\swhen\nSQLITE_DEFAULT_WAL_SYNCHRONOUS\sis\sset\sto\ssomething\sother\sthan\s2.
-D 2016-05-24T18:50:41.162
+C Enhance\sLemon\sand\sthe\sparser\stemplate\sso\sthat\sit\scan\sonce\sagain\sbuild\sparsers\nthat\shave\sno\sunreachable\sbranches.
+D 2016-05-24T18:55:08.844
 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7
@@ -1422,8 +1422,8 @@ F tool/fuzzershell.c 94019b185caceffc9f7c7b678a6489e42bc2aefa
 F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4
 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5
 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce
-F tool/lemon.c b4da2f0181b4defe538eb437eb96c721cf342d39
-F tool/lempar.c 8569dd3e4c22831e08e441ab7a0eb6bbefa1d38a
+F tool/lemon.c 09a96bed19955697a5e20c49ad863ec2005815a2
+F tool/lempar.c 1f69ad7531e39612915570a3d2c67a3cc1e9bbf0
 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862
 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca
 F tool/mkautoconfamal.sh e855df211ecbcc7131dee817110ff386cfb112f7
@@ -1494,7 +1494,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 37de3eab67f12ae1ce5bc8d5e541c64fc6b1fd80
-R a85ab0cafd821231f355609347ddd044
+P 61e239bc4310eff172e1e50d51522ecc75dd997e
+R 871f96c4fa63421d837cdbce37a6939a
 U drh
-Z c6593df9e63293d2b7fb6ab3cfe0f9b0
+Z 9f1d9f44ca67035c6f1f764382efebdf
index 0dbb5b2cbcc8f3754b808055f8b53f9d4b76f2be..b7546cc2980320a87a98bdc05a502e8d10bc4e8c 100644 (file)
@@ -1 +1 @@
-61e239bc4310eff172e1e50d51522ecc75dd997e
\ No newline at end of file
+41fd46e2962ba9a1e1f6867567499d1f6f5b8372
\ No newline at end of file
index d643b341e439aee7b413b26a21c0e3a539fc10f2..5f124601db4778e1f9123a9ca02ef8ec51a03318 100644 (file)
@@ -294,6 +294,7 @@ struct rule {
   int index;               /* An index number for this rule */
   int iRule;               /* Rule number as used in the generated tables */
   Boolean canReduce;       /* True if this rule is ever reduced */
+  Boolean doesReduce;      /* Reduce actions occur after optimization */
   struct rule *nextlhs;    /* Next rule with the same LHS */
   struct rule *next;       /* Next rule in the global list */
 };
@@ -4152,6 +4153,19 @@ void ReportTable(
   }
   free(ax);
 
+  /* Mark rules that are actually used for reduce actions after all
+  ** optimizations have been applied
+  */
+  for(rp=lemp->rule; rp; rp=rp->next) rp->doesReduce = LEMON_FALSE;
+  for(i=0; i<lemp->nxstate; i++){
+    struct action *ap;
+    for(ap=lemp->sorted[i]->ap; ap; ap=ap->next){
+      if( ap->type==REDUCE || ap->type==SHIFTREDUCE ){
+        ap->x.rp->doesReduce = i;
+      }
+    }
+  }
+
   /* Finish rendering the constants now that the action table has
   ** been computed */
   fprintf(out,"#define YYNSTATE             %d\n",lemp->nxstate);  lineno++;
@@ -4443,7 +4457,12 @@ void ReportTable(
     assert( rp->noCode );
     fprintf(out,"      /* (%d) ", rp->iRule);
     writeRuleText(out, rp);
-    fprintf(out, " */ yytestcase(yyruleno==%d);\n", rp->iRule); lineno++;
+    if( rp->doesReduce ){
+      fprintf(out, " */ yytestcase(yyruleno==%d);\n", rp->iRule); lineno++;
+    }else{
+      fprintf(out, " (OPTIMIZED OUT) */ assert(yyruleno!=%d);\n",
+              rp->iRule); lineno++;
+    }
   }
   fprintf(out,"        break;\n"); lineno++;
   tplt_xfer(lemp->name,in,out,&lineno);
index 7fb5fe2d0c3c2809d1144e9948c705dbc7e4990d..91f3549f31c1e525955585ef8e392cc4f27a16da 100644 (file)
@@ -739,7 +739,7 @@ static void yy_accept(
     fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
   }
 #endif
-  while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
+  assert( yypParser->yytos==yypParser->yystack );
   /* Here code is inserted which will be executed whenever the
   ** parser accepts */
 /*********** Begin %parse_accept code *****************************************/