/ Check-in [077a6bee]
Login

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

Overview
Comment:Fix an issue with lemon generating incorrect grammars. This issue does not effect SQLite.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 077a6bee2dd4668a5b13c37aa7d4c052350ec782
User & Date: drh 2010-01-06 13:07:31
Context
2010-01-06
17:19
Change the fts3 snippet function to return (hopefully) more relevant snippets in less time. check-in: 8a208223 user: dan tags: trunk
13:12
Update the OS-X branch to include all trunk changes through version 3.6.22. check-in: 541e2b48 user: drh tags: apple-osx
13:07
Fix an issue with lemon generating incorrect grammars. This issue does not effect SQLite. check-in: 077a6bee user: drh tags: trunk
00:00
Version 3.6.22 check-in: 28d0d771 user: drh tags: trunk, release
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tool/lemon.c.

   487    487   ** into the current action table.  Then reset the transaction set back
   488    488   ** to an empty set in preparation for a new round of acttab_action() calls.
   489    489   **
   490    490   ** Return the offset into the action table of the new transaction.
   491    491   */
   492    492   int acttab_insert(acttab *p){
   493    493     int i, j, k, n;
          494  +  int nActtab;     /* Number of slots in the p->aAction[] table */
   494    495     assert( p->nLookahead>0 );
   495    496   
   496    497     /* Make sure we have enough space to hold the expanded action table
   497    498     ** in the worst case.  The worst case occurs if the transaction set
   498    499     ** must be appended to the current action table
   499    500     */
   500    501     n = p->mxLookahead + 1;
   501         -  if( p->nAction + n >= p->nActionAlloc ){
          502  +  nActtab = p->nAction + n;
          503  +  if( nActtab >= p->nActionAlloc ){
   502    504       int oldAlloc = p->nActionAlloc;
   503    505       p->nActionAlloc = p->nAction + n + p->nActionAlloc + 20;
   504    506       p->aAction = realloc( p->aAction,
   505    507                             sizeof(p->aAction[0])*p->nActionAlloc);
   506    508       if( p->aAction==0 ){
   507    509         fprintf(stderr,"malloc failed\n");
   508    510         exit(1);
................................................................................
   512    514         p->aAction[i].action = -1;
   513    515       }
   514    516     }
   515    517   
   516    518     /* Scan the existing action table looking for an offset where we can
   517    519     ** insert the current transaction set.  Fall out of the loop when that
   518    520     ** offset is found.  In the worst case, we fall out of the loop when
   519         -  ** i reaches p->nAction, which means we append the new transaction set.
          521  +  ** i reaches nActtab, which means we append the new transaction set.
   520    522     **
   521    523     ** i is the index in p->aAction[] where p->mnLookahead is inserted.
   522    524     */
   523         -  for(i=p->nAction-1; i>=0; i--){
          525  +  for(i=nActtab-1; i>=0; i--){
   524    526       /* First look for an existing action table entry that can be reused */
   525    527       if( p->aAction[i].lookahead==p->mnLookahead ){
   526    528         if( p->aAction[i].action!=p->mnAction ) continue;
   527    529         for(j=0; j<p->nLookahead; j++){
   528    530           k = p->aLookahead[j].lookahead - p->mnLookahead + i;
   529    531           if( k<0 || k>=p->nAction ) break;
   530    532           if( p->aLookahead[j].lookahead!=p->aAction[k].lookahead ) break;
................................................................................
   539    541         if( n==p->nLookahead ){
   540    542           break;  /* Same as a prior transaction set */
   541    543         }
   542    544       }
   543    545     }
   544    546     if( i<0 ){
   545    547       /* If no reusable entry is found, look for an empty slot */
   546         -    for(i=0; i<p->nAction; i++){
          548  +    for(i=0; i<nActtab; i++){
   547    549         if( p->aAction[i].lookahead<0 ){
   548    550           for(j=0; j<p->nLookahead; j++){
   549    551             k = p->aLookahead[j].lookahead - p->mnLookahead + i;
   550    552             if( k<0 ) break;
   551    553             if( p->aAction[k].lookahead>=0 ) break;
   552    554           }
   553    555           if( j<p->nLookahead ) continue;