]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Optimizations to the LEMON parser template. (CVS 1143)
authordrh <drh@noemail.net>
Mon, 22 Dec 2003 14:53:19 +0000 (14:53 +0000)
committerdrh <drh@noemail.net>
Mon, 22 Dec 2003 14:53:19 +0000 (14:53 +0000)
FossilOrigin-Name: 06db29df8f0c1cd29e696537e622f0c5456056f5

manifest
manifest.uuid
tool/lempar.c

index 545cccbc2fbee86eb346100ba73ce86c09365574..b3298d1ce1c18077417b7edd5fd4fb716e159173 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\ssome\sminor\sproblems\swith\sthe\snew\stest4.c\smodule\sused\sfor\sdoing\sthread\ntesting.\s(CVS\s1142)
-D 2003-12-20T04:00:53
+C Optimizations\sto\sthe\sLEMON\sparser\stemplate.\s(CVS\s1143)
+D 2003-12-22T14:53:20
 F Makefile.in 0515ff9218ad8d5a8f6220f0494b8ef94c67013b
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -144,7 +144,7 @@ F test/view.test 1ee12c6f8f4791a2c0655120d5562a49400cfe53
 F test/where.test cb3a2ed062ce4b5f08aff2d08027c6a46d68c47b
 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
 F tool/lemon.c e37dcb5b8cdb16f4ac98338134bf8d8cd28e399f
-F tool/lempar.c 686d85ff4b11a790f52dd033612e6890a2a10f3c
+F tool/lempar.c 0b5e7a58634e0d448929b8e85f7981c2aa708d57
 F tool/memleak.awk 16ef9493dcd36146f806e75148f4bb0201a123ec
 F tool/memleak2.awk 9cc20c8e8f3c675efac71ea0721ee6874a1566e8
 F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x
@@ -179,7 +179,7 @@ F www/speed.tcl 2f6b1155b99d39adb185f900456d1d592c4832b3
 F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
 F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
 F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
-P 1e9689672c94e5ab89f07099c1402e157c8b02c1
-R a1fd48855a547ffbdcf831309e005755
+P 952924084aac4a7fa84a7cb7aaac869d35db1896
+R 7ab32ac7ee9a5574dd03ea51da394001
 U drh
-Z d63babfeaee4d16e2d4a389b00f50ce6
+Z bb57c31f5dd8de3fdff4945aa0883461
index 2c13c97efdca3d5968c4c66be82bd9068c03bcc9..155db807146b694b2800f8da5cc8b21caa7deb12 100644 (file)
@@ -1 +1 @@
-952924084aac4a7fa84a7cb7aaac869d35db1896
\ No newline at end of file
+06db29df8f0c1cd29e696537e622f0c5456056f5
\ No newline at end of file
index bf262c3fc781a7977d3f4613c39f2d2561461d7e..ee1edbfa7c6351bda8c170ca4d617edb87e7ec78 100644 (file)
@@ -151,7 +151,6 @@ typedef struct yyStackEntry yyStackEntry;
 struct yyParser {
   int yyidx;                    /* Index of top element in stack */
   int yyerrcnt;                 /* Shifts left before out of the error */
-  yyStackEntry *yytop;          /* Pointer to the top stack element */
   ParseARG_SDECL                /* A place to hold %extra_argument */
   yyStackEntry yystack[YYSTACKDEPTH];  /* The parser's stack */
 };
@@ -274,19 +273,19 @@ static void yy_destructor(YYCODETYPE yymajor, YYMINORTYPE *yypminor){
 */
 static int yy_pop_parser_stack(yyParser *pParser){
   YYCODETYPE yymajor;
+  yyStackEntry *yytos = &pParser->yystack[pParser->yyidx];
 
   if( pParser->yyidx<0 ) return 0;
 #ifndef NDEBUG
   if( yyTraceFILE && pParser->yyidx>=0 ){
     fprintf(yyTraceFILE,"%sPopping %s\n",
       yyTracePrompt,
-      yyTokenName[pParser->yytop->major]);
+      yyTokenName[yytos->major]);
   }
 #endif
-  yymajor = pParser->yytop->major;
-  yy_destructor( yymajor, &pParser->yytop->minor);
+  yymajor = yytos->major;
+  yy_destructor( yymajor, &yytos->minor);
   pParser->yyidx--;
-  pParser->yytop--;
   return yymajor;
 }
 
@@ -325,11 +324,12 @@ static int yy_find_shift_action(
   int iLookAhead            /* The look-ahead token */
 ){
   int i;
+  int stateno = pParser->yystack[pParser->yyidx].stateno;
  
   /* if( pParser->yyidx<0 ) return YY_NO_ACTION;  */
-  i = yy_shift_ofst[pParser->yytop->stateno];
+  i = yy_shift_ofst[stateno];
   if( i==YY_SHIFT_USE_DFLT ){
-    return yy_default[pParser->yytop->stateno];
+    return yy_default[stateno];
   }
   if( iLookAhead==YYNOCODE ){
     return YY_NO_ACTION;
@@ -349,7 +349,7 @@ static int yy_find_shift_action(
       return yy_find_shift_action(pParser, iFallback);
     }
 #endif
-    return yy_default[pParser->yytop->stateno];
+    return yy_default[stateno];
   }else{
     return yy_action[i];
   }
@@ -368,17 +368,18 @@ static int yy_find_reduce_action(
   int iLookAhead            /* The look-ahead token */
 ){
   int i;
+  int stateno = pParser->yystack[pParser->yyidx].stateno;
  
-  i = yy_reduce_ofst[pParser->yytop->stateno];
+  i = yy_reduce_ofst[stateno];
   if( i==YY_REDUCE_USE_DFLT ){
-    return yy_default[pParser->yytop->stateno];
+    return yy_default[stateno];
   }
   if( iLookAhead==YYNOCODE ){
     return YY_NO_ACTION;
   }
   i += iLookAhead;
   if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
-    return yy_default[pParser->yytop->stateno];
+    return yy_default[stateno];
   }else{
     return yy_action[i];
   }
@@ -393,12 +394,11 @@ static void yy_shift(
   int yyMajor,                  /* The major token to shift in */
   YYMINORTYPE *yypMinor         /* Pointer ot the minor token to shift in */
 ){
+  yyStackEntry *yytos;
   yypParser->yyidx++;
-  yypParser->yytop++;
   if( yypParser->yyidx>=YYSTACKDEPTH ){
      ParseARG_FETCH;
      yypParser->yyidx--;
-     yypParser->yytop--;
 #ifndef NDEBUG
      if( yyTraceFILE ){
        fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
@@ -411,9 +411,10 @@ static void yy_shift(
      ParseARG_STORE; /* Suppress warning about unused %extra_argument var */
      return;
   }
-  yypParser->yytop->stateno = yyNewState;
-  yypParser->yytop->major = yyMajor;
-  yypParser->yytop->minor = *yypMinor;
+  yytos = &yypParser->yystack[yypParser->yyidx];
+  yytos->stateno = yyNewState;
+  yytos->major = yyMajor;
+  yytos->minor = *yypMinor;
 #ifndef NDEBUG
   if( yyTraceFILE && yypParser->yyidx>0 ){
     int i;
@@ -452,7 +453,7 @@ static void yy_reduce(
   yyStackEntry *yymsp;            /* The top of the parser's stack */
   int yysize;                     /* Amount to pop the stack */
   ParseARG_FETCH;
-  yymsp = yypParser->yytop;
+  yymsp = &yypParser->yystack[yypParser->yyidx];
 #ifndef NDEBUG
   if( yyTraceFILE && yyruleno>=0 
         && yyruleno<sizeof(yyRuleName)/sizeof(yyRuleName[0]) ){
@@ -475,7 +476,6 @@ static void yy_reduce(
   yygoto = yyRuleInfo[yyruleno].lhs;
   yysize = yyRuleInfo[yyruleno].nrhs;
   yypParser->yyidx -= yysize;
-  yypParser->yytop -= yysize;
   yyact = yy_find_reduce_action(yypParser,yygoto);
   if( yyact < YYNSTATE ){
     yy_shift(yypParser,yyact,yygoto,&yygotominor);
@@ -573,9 +573,8 @@ void Parse(
     if( yymajor==0 ) return;
     yypParser->yyidx = 0;
     yypParser->yyerrcnt = -1;
-    yypParser->yytop = &yypParser->yystack[0];
-    yypParser->yytop->stateno = 0;
-    yypParser->yytop->major = 0;
+    yypParser->yystack[0].stateno = 0;
+    yypParser->yystack[0].major = 0;
   }
   yyminorunion.yy0 = yyminor;
   yyendofinput = (yymajor==0);
@@ -600,6 +599,7 @@ void Parse(
     }else if( yyact < YYNSTATE + YYNRULE ){
       yy_reduce(yypParser,yyact-YYNSTATE);
     }else if( yyact == YY_ERROR_ACTION ){
+      int yymx;
 #ifndef NDEBUG
       if( yyTraceFILE ){
         fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
@@ -628,7 +628,8 @@ void Parse(
       if( yypParser->yyerrcnt<0 ){
         yy_syntax_error(yypParser,yymajor,yyminorunion);
       }
-      if( yypParser->yytop->major==YYERRORSYMBOL || yyerrorhit ){
+      yymx = yypParser->yystack[yypParser->yyidx].major;
+      if( yymx==YYERRORSYMBOL || yyerrorhit ){
 #ifndef NDEBUG
         if( yyTraceFILE ){
           fprintf(yyTraceFILE,"%sDiscard input token %s\n",
@@ -640,7 +641,7 @@ void Parse(
       }else{
          while(
           yypParser->yyidx >= 0 &&
-          yypParser->yytop->major != YYERRORSYMBOL &&
+          yymx != YYERRORSYMBOL &&
           (yyact = yy_find_shift_action(yypParser,YYERRORSYMBOL)) >= YYNSTATE
         ){
           yy_pop_parser_stack(yypParser);
@@ -649,7 +650,7 @@ void Parse(
           yy_destructor(yymajor,&yyminorunion);
           yy_parse_failed(yypParser);
           yymajor = YYNOCODE;
-        }else if( yypParser->yytop->major!=YYERRORSYMBOL ){
+        }else if( yymx!=YYERRORSYMBOL ){
           YYMINORTYPE u2;
           u2.YYERRSYMDT = 0;
           yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2);