]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
The lemon parser generator now inserts yytestcase() macros on reduce action
authordrh <drh@noemail.net>
Fri, 12 Jun 2009 13:53:51 +0000 (13:53 +0000)
committerdrh <drh@noemail.net>
Fri, 12 Jun 2009 13:53:51 +0000 (13:53 +0000)
and on each destructor, to verify that all have been executed.  yytestcase()
is a no-op by default but can be set to something more useful inside
of %include. (CVS 6755)

FossilOrigin-Name: fe9c9177340a3dc372ffa1b851030d005e0c46db

manifest
manifest.uuid
src/parse.y
tool/lemon.c
tool/lempar.c

index f263a50b64a243bcf56e69742056a9d7d32b8cec..3819545e305d05f890c0b0c2029e3e898c60c829 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C In\slemon:\somit\sunused\sentries\sfrom\sthe\send\sof\sthe\syyFallback\sarray.\s(CVS\s6754)
-D 2009-06-12T12:50:51
+C The\slemon\sparser\sgenerator\snow\sinserts\syytestcase()\smacros\son\sreduce\saction\nand\son\seach\sdestructor,\sto\sverify\sthat\sall\shave\sbeen\sexecuted.\s\syytestcase()\nis\sa\sno-op\sby\sdefault\sbut\scan\sbe\sset\sto\ssomething\smore\suseful\sinside\nof\s%include.\s(CVS\s6755)
+D 2009-06-12T13:53:52
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 8b8fb7823264331210cddf103831816c286ba446
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -148,7 +148,7 @@ F src/os_unix.c e55d977c516ed880a2f83f0610b019efd9f8bc06
 F src/os_win.c 725c38a524d168ce280446ad8761d731bc516405
 F src/pager.c efdd56a49622fe87d5cf4b6e69aeb62b45bcb9b0
 F src/pager.h 73f481a308a873ccd626d97331c081db3b53e2e5
-F src/parse.y d4bade53de7a0ed17d6a06f89b171492c844502e
+F src/parse.y bab89225c2543a350ef96995926520bbbd781aba
 F src/pcache.c 395f752a13574120bd7513a400ba02a265aaa76d
 F src/pcache.h 9b927ccc5a538e31b4c3bc7eec4f976db42a1324
 F src/pcache1.c 97e7e8e6e34026fb43b47d08532b0c02e959c26c
@@ -714,8 +714,8 @@ F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
 F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439
 F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4
 F tool/genfkey.test 405a43d54f1646bfaa7a84b03bb959aef62a3a49
-F tool/lemon.c ef864b9566d4e62cc9d0ee4ac937dd1264490d27
-F tool/lempar.c d2fbe360eb398075947ba6de9197f99247d3d5a8
+F tool/lemon.c 19eb5bf696f833a4e22ee13a93b3f6b6038f41e3
+F tool/lempar.c 2ed70b3fc896a47e07fedfe543324f008f53d223
 F tool/mkkeywordhash.c 511a848b2ac7a3d93f36adc1e1086b4c5741224b
 F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x
 F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
@@ -734,7 +734,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
-P a17e3317176772446abdc8ebe6fb6f0d3b7ac018
-R 99671adf6d4ab3cc561d188e482f7017
+P 9cfbe2ba68470a2850a7d7a64eb088f7b422a3e5
+R b3c179781de3d21b42dbda7713a85945
 U drh
-Z 201c718738a93aa053a9925b7422ae62
+Z 9899f5ed2d564d373727b1fd600efdbb
index a8fa9862472a2684567c65c051470a84cb8a0fdf..961d3545a537978663decdd27bc2960bf56d4001 100644 (file)
@@ -1 +1 @@
-9cfbe2ba68470a2850a7d7a64eb088f7b422a3e5
\ No newline at end of file
+fe9c9177340a3dc372ffa1b851030d005e0c46db
\ No newline at end of file
index 483757ff0cb27a984d8be91dc78706afb5b62516..254f0297aee441185c56f758b55d0689223b588d 100644 (file)
@@ -14,7 +14,7 @@
 ** the parser.  Lemon will also generate a header file containing
 ** numeric codes for all of the tokens.
 **
-** @(#) $Id: parse.y,v 1.281 2009/06/12 12:04:16 drh Exp $
+** @(#) $Id: parse.y,v 1.282 2009/06/12 13:53:52 drh Exp $
 */
 
 // All token codes are small integers with #defines that begin with "TK_"
 */
 #define YYNOERRORRECOVERY 1
 
+/*
+** Make yytestcase() the same as testcase()
+*/
+#define yytestcase(X) testcase(X)
+
 /*
 ** An instance of this structure holds information about the
 ** LIMIT clause of a SELECT statement.
index d69efae77844f4b3aa68361b9c893bcb7882aa3d..4754d2c068b769b26a93fa449106acb76a6e6531 100644 (file)
@@ -3599,7 +3599,7 @@ int mhflag;     /* Output in makeheaders format if true */
 
   /* Generate the defines */
   fprintf(out,"#define YYCODETYPE %s\n",
-    minimum_size_type(0, lemp->nsymbol+5)); lineno++;
+    minimum_size_type(0, lemp->nsymbol+1)); lineno++;
   fprintf(out,"#define YYNOCODE %d\n",lemp->nsymbol+1);  lineno++;
   fprintf(out,"#define YYACTIONTYPE %s\n",
     minimum_size_type(0, lemp->nstate+lemp->nrule+5));  lineno++;
@@ -3864,8 +3864,8 @@ int mhflag;     /* Output in makeheaders format if true */
         fprintf(out, "      /* TERMINAL Destructor */\n"); lineno++;
         once = 0;
       }
-      fprintf(out,"    case %d: /* %s */\n",
-              sp->index, sp->name); lineno++;
+      fprintf(out,"    case %d: /* %s */ yytestcase(yymajor==%d);\n",
+              sp->index, sp->name, sp->index); lineno++;
     }
     for(i=0; i<lemp->nsymbol && lemp->symbols[i]->type!=TERMINAL; i++);
     if( i<lemp->nsymbol ){
@@ -3884,8 +3884,8 @@ int mhflag;     /* Output in makeheaders format if true */
         fprintf(out, "      /* Default NON-TERMINAL Destructor */\n"); lineno++;
         once = 0;
       }
-      fprintf(out,"    case %d: /* %s */\n",
-              sp->index, sp->name); lineno++;
+      fprintf(out,"    case %d: /* %s */ yytestcase(yymajor==%d);\n",
+              sp->index, sp->name, sp->index); lineno++;
       dflt_sp = sp;
     }
     if( dflt_sp!=0 ){
@@ -3896,8 +3896,8 @@ int mhflag;     /* Output in makeheaders format if true */
   for(i=0; i<lemp->nsymbol; i++){
     struct symbol *sp = lemp->symbols[i];
     if( sp==0 || sp->type==TERMINAL || sp->destructor==0 ) continue;
-    fprintf(out,"    case %d: /* %s */\n",
-            sp->index, sp->name); lineno++;
+    fprintf(out,"    case %d: /* %s */ yytestcase(yymajor==%d);\n",
+            sp->index, sp->name, sp->index); lineno++;
 
     /* Combine duplicate destructors into a single case */
     for(j=i+1; j<lemp->nsymbol; j++){
@@ -3905,8 +3905,8 @@ int mhflag;     /* Output in makeheaders format if true */
       if( sp2 && sp2->type!=TERMINAL && sp2->destructor
           && sp2->dtnum==sp->dtnum
           && strcmp(sp->destructor,sp2->destructor)==0 ){
-         fprintf(out,"    case %d: /* %s */\n",
-                 sp2->index, sp2->name); lineno++;
+         fprintf(out,"    case %d: /* %s */ yytestcase(yymajor==%d);\n",
+                 sp2->index, sp2->name, sp2->index); lineno++;
          sp2->destructor = 0;
       }
     }
@@ -3944,7 +3944,7 @@ int mhflag;     /* Output in makeheaders format if true */
       if( rp2->code==rp->code ){
         fprintf(out,"      case %d: /* ", rp2->index);
         writeRuleText(out, rp2);
-        fprintf(out," */\n"); lineno++;
+        fprintf(out," */ yytestcase(yyruleno==%d);\n", rp2->index); lineno++;
         rp2->code = 0;
       }
     }
index 4ab90c2479c29ba27435ca1144e485fd9cac2dfa..774b875e21dab65e0e4c65a19e5f7b09e2bd2d2b 100644 (file)
 ** YYMINORTYPE objects to zero. */
 static const YYMINORTYPE yyzerominor = { 0 };
 
+/* Define the yytestcase() macro to be a no-op if is not already defined
+** otherwise.
+**
+** Applications can choose to define yytestcase() in the %include section
+** to a macro that can assist in verifying code coverage.  For production
+** code the yytestcase() macro should be turned off.  But it is useful
+** for testing.
+*/
+#ifndef yytestcase
+# define yytestcase(X)
+#endif
+
 
 /* Next are the tables used to determine what action to take based on the
 ** current state and lookahead token.  These tables are used to implement