]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Improved comments on the lempar.c parser template. Adjust the
authordrh <drh@noemail.net>
Wed, 10 Aug 2016 13:30:43 +0000 (13:30 +0000)
committerdrh <drh@noemail.net>
Wed, 10 Aug 2016 13:30:43 +0000 (13:30 +0000)
YY_SHIFT_USE_DFLT constant in the Lemon-generated parser tables so as
to guarantee that it is always out of range of the yy_lookahead[] table.

FossilOrigin-Name: 83622f3f50030e4d6abafb99d99742928aaf157c

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

index 316b95fb867cc01e49d16e5806445a93e254593a..a0534bfabe981c9085e5444d6a6eec50a0a4a027 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\spcache1TruncateUnsafe()\srun\sfaster\sfor\sthe\scase\swhere\siLimit\sis\nvery\sclose\sto\siMaxKey.
-D 2016-08-10T11:50:12.345
+C Improved\scomments\son\sthe\slempar.c\sparser\stemplate.\s\sAdjust\sthe\nYY_SHIFT_USE_DFLT\sconstant\sin\sthe\sLemon-generated\sparser\stables\sso\sas\nto\sguarantee\sthat\sit\sis\salways\sout\sof\srange\sof\sthe\syy_lookahead[]\stable.
+D 2016-08-10T13:30:43.279
 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a
@@ -1437,8 +1437,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 09a96bed19955697a5e20c49ad863ec2005815a2
-F tool/lempar.c 321ebbf1c85ab5435434042590eca0616da24b3d
+F tool/lemon.c e3aa9ba3469804d7cae13b5e041aab192b7b381a
+F tool/lempar.c 147e42a5cd83ce38275fde0d07a5df3330cb9b3b
 F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9
 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862
 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca
@@ -1510,8 +1510,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 ba6663beefcc8060e6f3be6ab37c13fdbb08b7de
-Q +9ab53605d562a926c5620cba9dc96a3b812a432f
-R 045183d4dc58e68027bf139105903731
+P b07a26df06a2ffb946ff8a1cc7f43eaf701a94b5
+R f8409033fe00bbe724670b3d36a1f97d
 U drh
-Z 7fb6739dae3ac730e38720df5d5c1de9
+Z c9080bc44cd5d5b39b4e8d736cb94a4a
index 5bb9a78a8394ee697641deaa3a475552f5b008ca..d2f3f5ca4a5b00983c0d81df468f8ba94b5287a5 100644 (file)
@@ -1 +1 @@
-b07a26df06a2ffb946ff8a1cc7f43eaf701a94b5
\ No newline at end of file
+83622f3f50030e4d6abafb99d99742928aaf157c
\ No newline at end of file
index 5f124601db4778e1f9123a9ca02ef8ec51a03318..df758a5da6880a457f9ec714d852fe4319c6ffbe 100644 (file)
@@ -4231,20 +4231,21 @@ void ReportTable(
   fprintf(out, "};\n"); lineno++;
 
   /* Output the yy_shift_ofst[] table */
-  fprintf(out, "#define YY_SHIFT_USE_DFLT (%d)\n", mnTknOfst-1); lineno++;
   n = lemp->nxstate;
   while( n>0 && lemp->sorted[n-1]->iTknOfst==NO_OFFSET ) n--;
-  fprintf(out, "#define YY_SHIFT_COUNT (%d)\n", n-1); lineno++;
-  fprintf(out, "#define YY_SHIFT_MIN   (%d)\n", mnTknOfst); lineno++;
-  fprintf(out, "#define YY_SHIFT_MAX   (%d)\n", mxTknOfst); lineno++;
+  fprintf(out, "#define YY_SHIFT_USE_DFLT (%d)\n", lemp->nactiontab); lineno++;
+  fprintf(out, "#define YY_SHIFT_COUNT    (%d)\n", n-1); lineno++;
+  fprintf(out, "#define YY_SHIFT_MIN      (%d)\n", mnTknOfst); lineno++;
+  fprintf(out, "#define YY_SHIFT_MAX      (%d)\n", mxTknOfst); lineno++;
   fprintf(out, "static const %s yy_shift_ofst[] = {\n", 
-          minimum_size_type(mnTknOfst-1, mxTknOfst, &sz)); lineno++;
+       minimum_size_type(mnTknOfst, lemp->nterminal+lemp->nactiontab, &sz));
+       lineno++;
   lemp->tablesize += n*sz;
   for(i=j=0; i<n; i++){
     int ofst;
     stp = lemp->sorted[i];
     ofst = stp->iTknOfst;
-    if( ofst==NO_OFFSET ) ofst = mnTknOfst - 1;
+    if( ofst==NO_OFFSET ) ofst = lemp->nactiontab;
     if( j==0 ) fprintf(out," /* %5d */ ", i);
     fprintf(out, " %4d,", ofst);
     if( j==9 || i==n-1 ){
index 74906ae17fd7906d58feeca9fe74ba57f217f3c9..61d19451e9416d26701d7f2eec5faec9f183fb04 100644 (file)
 **
 **   N between YY_MIN_REDUCE            Reduce by rule N-YY_MIN_REDUCE
 **     and YY_MAX_REDUCE
-
+**
 **   N == YY_ERROR_ACTION               A syntax error has occurred.
 **
 **   N == YY_ACCEPT_ACTION              The parser accepts its input.
 **                                      slots in the yy_action[] table.
 **
 ** The action table is constructed as a single large table named yy_action[].
-** Given state S and lookahead X, the action is computed as
+** Given state S and lookahead X, the action is computed as either:
 **
-**      yy_action[ yy_shift_ofst[S] + X ]
+**    (A)   N = yy_action[ yy_shift_ofst[S] + X ]
+**    (B)   N = yy_default[S]
 **
-** If the index value yy_shift_ofst[S]+X is out of range or if the value
-** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
-** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
-** and that yy_default[S] should be used instead.  
+** The (A) formula is preferred.  The B formula is used instead if:
+**    (1)  The yy_shift_ofst[S]+X value is out of range, or
+**    (2)  yy_lookahead[yy_shift_ofst[S]+X] is not equal to X, or
+**    (3)  yy_shift_ofst[S] equal YY_SHIFT_USE_DFLT.
+** (Implementation note: YY_SHIFT_USE_DFLT is chosen so that
+** YY_SHIFT_USE_DFLT+X will be out of range for all possible lookaheads X.
+** Hence only tests (1) and (2) need to be evaluated.)
 **
-** The formula above is for computing the action when the lookahead is
+** The formulas above are for computing the action when the lookahead is
 ** a terminal symbol.  If the lookahead is a non-terminal (as occurs after
 ** a reduce action) then the yy_reduce_ofst[] array is used in place of
 ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of