/ Check-in [83622f3f]
Login

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

Overview
Comment:Improved comments on the lempar.c parser template. Adjust the 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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 83622f3f50030e4d6abafb99d99742928aaf157c
User & Date: drh 2016-08-10 13:30:43
Context
2016-08-10
13:34
Increment the version number to 3.15. check-in: 8c2701e7 user: drh tags: trunk
13:30
Improved comments on the lempar.c parser template. Adjust the 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. check-in: 83622f3f user: drh tags: trunk
11:50
Fix pcache1TruncateUnsafe() run faster for the case where iLimit is very close to iMaxKey. check-in: b07a26df user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tool/lemon.c.

  4227   4227       }else{
  4228   4228         j++;
  4229   4229       }
  4230   4230     }
  4231   4231     fprintf(out, "};\n"); lineno++;
  4232   4232   
  4233   4233     /* Output the yy_shift_ofst[] table */
  4234         -  fprintf(out, "#define YY_SHIFT_USE_DFLT (%d)\n", mnTknOfst-1); lineno++;
  4235   4234     n = lemp->nxstate;
  4236   4235     while( n>0 && lemp->sorted[n-1]->iTknOfst==NO_OFFSET ) n--;
  4237         -  fprintf(out, "#define YY_SHIFT_COUNT (%d)\n", n-1); lineno++;
  4238         -  fprintf(out, "#define YY_SHIFT_MIN   (%d)\n", mnTknOfst); lineno++;
  4239         -  fprintf(out, "#define YY_SHIFT_MAX   (%d)\n", mxTknOfst); lineno++;
         4236  +  fprintf(out, "#define YY_SHIFT_USE_DFLT (%d)\n", lemp->nactiontab); lineno++;
         4237  +  fprintf(out, "#define YY_SHIFT_COUNT    (%d)\n", n-1); lineno++;
         4238  +  fprintf(out, "#define YY_SHIFT_MIN      (%d)\n", mnTknOfst); lineno++;
         4239  +  fprintf(out, "#define YY_SHIFT_MAX      (%d)\n", mxTknOfst); lineno++;
  4240   4240     fprintf(out, "static const %s yy_shift_ofst[] = {\n", 
  4241         -          minimum_size_type(mnTknOfst-1, mxTknOfst, &sz)); lineno++;
         4241  +       minimum_size_type(mnTknOfst, lemp->nterminal+lemp->nactiontab, &sz));
         4242  +       lineno++;
  4242   4243     lemp->tablesize += n*sz;
  4243   4244     for(i=j=0; i<n; i++){
  4244   4245       int ofst;
  4245   4246       stp = lemp->sorted[i];
  4246   4247       ofst = stp->iTknOfst;
  4247         -    if( ofst==NO_OFFSET ) ofst = mnTknOfst - 1;
         4248  +    if( ofst==NO_OFFSET ) ofst = lemp->nactiontab;
  4248   4249       if( j==0 ) fprintf(out," /* %5d */ ", i);
  4249   4250       fprintf(out, " %4d,", ofst);
  4250   4251       if( j==9 || i==n-1 ){
  4251   4252         fprintf(out, "\n"); lineno++;
  4252   4253         j = 0;
  4253   4254       }else{
  4254   4255         j++;

Changes to tool/lempar.c.

   112    112   **                                      token onto the stack and goto state N.
   113    113   **
   114    114   **   N between YY_MIN_SHIFTREDUCE       Shift to an arbitrary state then
   115    115   **     and YY_MAX_SHIFTREDUCE           reduce by rule N-YY_MIN_SHIFTREDUCE.
   116    116   **
   117    117   **   N between YY_MIN_REDUCE            Reduce by rule N-YY_MIN_REDUCE
   118    118   **     and YY_MAX_REDUCE
   119         -
          119  +**
   120    120   **   N == YY_ERROR_ACTION               A syntax error has occurred.
   121    121   **
   122    122   **   N == YY_ACCEPT_ACTION              The parser accepts its input.
   123    123   **
   124    124   **   N == YY_NO_ACTION                  No such action.  Denotes unused
   125    125   **                                      slots in the yy_action[] table.
   126    126   **
   127    127   ** The action table is constructed as a single large table named yy_action[].
   128         -** Given state S and lookahead X, the action is computed as
          128  +** Given state S and lookahead X, the action is computed as either:
   129    129   **
   130         -**      yy_action[ yy_shift_ofst[S] + X ]
          130  +**    (A)   N = yy_action[ yy_shift_ofst[S] + X ]
          131  +**    (B)   N = yy_default[S]
   131    132   **
   132         -** If the index value yy_shift_ofst[S]+X is out of range or if the value
   133         -** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
   134         -** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
   135         -** and that yy_default[S] should be used instead.  
          133  +** The (A) formula is preferred.  The B formula is used instead if:
          134  +**    (1)  The yy_shift_ofst[S]+X value is out of range, or
          135  +**    (2)  yy_lookahead[yy_shift_ofst[S]+X] is not equal to X, or
          136  +**    (3)  yy_shift_ofst[S] equal YY_SHIFT_USE_DFLT.
          137  +** (Implementation note: YY_SHIFT_USE_DFLT is chosen so that
          138  +** YY_SHIFT_USE_DFLT+X will be out of range for all possible lookaheads X.
          139  +** Hence only tests (1) and (2) need to be evaluated.)
   136    140   **
   137         -** The formula above is for computing the action when the lookahead is
          141  +** The formulas above are for computing the action when the lookahead is
   138    142   ** a terminal symbol.  If the lookahead is a non-terminal (as occurs after
   139    143   ** a reduce action) then the yy_reduce_ofst[] array is used in place of
   140    144   ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
   141    145   ** YY_SHIFT_USE_DFLT.
   142    146   **
   143    147   ** The following are the tables generated in this section:
   144    148   **