/ Check-in [9235b0cf]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Improve the Lemon parser template (lempar.c) so that it avoids unnecessary work when the grammer defines YYNOERRORRECOVERY (as SQLite does). Slightly smaller and faster code results.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9235b0cf6a37712ae9e5deeb1e5ee064dd5511fa
User & Date: drh 2016-02-16 01:01:43
Context
2016-02-16
13:04
Minor simplification to the tokenizer. Slightly smaller and faster. check-in: 9570b6b4 user: drh tags: trunk
01:01
Improve the Lemon parser template (lempar.c) so that it avoids unnecessary work when the grammer defines YYNOERRORRECOVERY (as SQLite does). Slightly smaller and faster code results. check-in: 9235b0cf user: drh tags: trunk
2016-02-15
23:46
Fix a harmless compiler warning in FTS5. check-in: e52c9075 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tool/lempar.c.

   207    207   /* The state of the parser is completely contained in an instance of
   208    208   ** the following structure */
   209    209   struct yyParser {
   210    210     int yyidx;                    /* Index of top element in stack */
   211    211   #ifdef YYTRACKMAXSTACKDEPTH
   212    212     int yyidxMax;                 /* Maximum value of yyidx */
   213    213   #endif
          214  +#ifndef YYNOERRORRECOVERY
   214    215     int yyerrcnt;                 /* Shifts left before out of the error */
          216  +#endif
   215    217     ParseARG_SDECL                /* A place to hold %extra_argument */
   216    218   #if YYSTACKDEPTH<=0
   217    219     int yystksz;                  /* Current side of the stack */
   218    220     yyStackEntry *yystack;        /* The parser's stack */
   219    221   #else
   220    222     yyStackEntry yystack[YYSTACKDEPTH];  /* The parser's stack */
   221    223   #endif
................................................................................
   770    772         /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/
   771    773         yyminorunion = yyzerominor;
   772    774         yyStackOverflow(yypParser, &yyminorunion);
   773    775         return;
   774    776       }
   775    777   #endif
   776    778       yypParser->yyidx = 0;
          779  +#ifndef YYNOERRORRECOVERY
   777    780       yypParser->yyerrcnt = -1;
          781  +#endif
   778    782       yypParser->yystack[0].stateno = 0;
   779    783       yypParser->yystack[0].major = 0;
   780    784   #ifndef NDEBUG
   781    785       if( yyTraceFILE ){
   782    786         fprintf(yyTraceFILE,"%sInitialize. Empty stack. State 0\n",
   783    787                 yyTracePrompt);
   784    788       }
................................................................................
   797    801   #endif
   798    802   
   799    803     do{
   800    804       yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
   801    805       if( yyact <= YY_MAX_SHIFTREDUCE ){
   802    806         if( yyact > YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
   803    807         yy_shift(yypParser,yyact,yymajor,&yyminorunion);
          808  +#ifndef YYNOERRORRECOVERY
   804    809         yypParser->yyerrcnt--;
          810  +#endif
   805    811         yymajor = YYNOCODE;
   806    812       }else if( yyact <= YY_MAX_REDUCE ){
   807    813         yy_reduce(yypParser,yyact-YY_MIN_REDUCE);
   808    814       }else{
   809    815         assert( yyact == YY_ERROR_ACTION );
   810    816   #ifdef YYERRORSYMBOL
   811    817         int yymx;