diff options
author | drh <drh@noemail.net> | 2019-08-28 02:09:47 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2019-08-28 02:09:47 +0000 |
commit | 2e51716b1520fc6e681e9578d681e2e60ae6590f (patch) | |
tree | 2a5a46b7e58ecf23d4c4c5179a8f981817a5137b /tool/lemon.c | |
parent | 8085d53d3c5f853c592cb2ffdb7e49a219c962be (diff) | |
download | sqlite-2e51716b1520fc6e681e9578d681e2e60ae6590f.tar.gz sqlite-2e51716b1520fc6e681e9578d681e2e60ae6590f.zip |
Increase the size of the yy_lookahead table so that it is never necessary to
down bounds checking on the index.
FossilOrigin-Name: bafd872398e58766e996963372c7acc03a1e20a6d39a3867ca45d3ea0ed2ac1d
Diffstat (limited to 'tool/lemon.c')
-rw-r--r-- | tool/lemon.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tool/lemon.c b/tool/lemon.c index 4416f67bb..3daa6d38c 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -4153,6 +4153,7 @@ void ReportTable( struct rule *rp; struct acttab *pActtab; int i, j, n, sz; + int nLookAhead; int szActionType; /* sizeof(YYACTIONTYPE) */ int szCodeType; /* sizeof(YYCODETYPE) */ const char *name; @@ -4403,13 +4404,29 @@ void ReportTable( if( la<0 ) la = lemp->nsymbol; if( j==0 ) fprintf(out," /* %5d */ ", i); fprintf(out, " %4d,", la); - if( j==9 || i==n-1 ){ + if( j==9 ){ + fprintf(out, "\n"); lineno++; + j = 0; + }else{ + j++; + } + } + /* Add extra entries to the end of the yy_lookahead[] table so that + ** yy_shift_ofst[]+iToken will always be a valid index into the array, + ** even for the largest possible value of yy_shift_ofst[] and iToken. */ + nLookAhead = lemp->nterminal + lemp->nactiontab; + while( i<nLookAhead ){ + if( j==0 ) fprintf(out," /* %5d */ ", i); + fprintf(out, " %4d,", lemp->nterminal); + if( j==9 ){ fprintf(out, "\n"); lineno++; j = 0; }else{ j++; } + i++; } + if( j>0 ) fprintf(out, "\n"); lineno++; fprintf(out, "};\n"); lineno++; /* Output the yy_shift_ofst[] table */ |