Another attempt at fixing the table generator in lemon. Again, this does

not effect the SQLite grammar.

FossilOrigin-Name: e22c090f35b3a2bac64781d33aa1123ed765dbbf
This commit is contained in:
drh 2010-01-07 03:53:03 +00:00
parent c06013dca7
commit 8dc3e8f3e6
3 changed files with 60 additions and 22 deletions

View File

@ -1,5 +1,8 @@
C Fix\sa\ssegfault\sthat\scan\soccur\sfollowing\san\sOOM\sin\sthe\sFTS3\ssnippet()\sfunction
D 2010-01-06T18:36:27
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
C Another\sattempt\sat\sfixing\sthe\stable\sgenerator\sin\slemon.\s\sAgain,\sthis\sdoes\nnot\seffect\sthe\sSQLite\sgrammar.
D 2010-01-07T03:53:04
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -760,7 +763,7 @@ F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439
F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4
F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5
F tool/lemon.c f3a625c38b5621674f27775b307ea100b6a7b62d
F tool/lemon.c 102000370ae3de57e1198faffbccf3b1d71d6f75
F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc
F tool/mkkeywordhash.c d2e6b4a5965e23afb80fbe74bb54648cd371f309
F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e
@ -784,7 +787,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 8a208223a74d451f60d9cd707d63fb7d157d1737
R 83ede8c4e7ec647a7bad4aa471ed9d37
U dan
Z d18fd5f25c622057e3ab533cbe2570aa
P c7e5966e3b031672f149d0b6e1f75f9bc40868fa
R c71e215e8efe7e980817f2247ed81780
U drh
Z eaa58ce585624f7f98bd421d59de7fbe
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFLRVqjoxKgR168RlERAr98AJ0fYlm+0rcqam2O2GKZRNuoWdSXiwCeKGNO
zIN2JBTaxHsvBtPlPjm5964=
=BXEN
-----END PGP SIGNATURE-----

View File

@ -1 +1 @@
c7e5966e3b031672f149d0b6e1f75f9bc40868fa
e22c090f35b3a2bac64781d33aa1123ed765dbbf

View File

@ -409,7 +409,23 @@ char *arg;
/*
** The state of the yy_action table under construction is an instance of
** the following structure
** the following structure.
**
** The yy_action table maps the pair (state_number, lookahead) into an
** action_number. The table is an array of integers pairs. The state_number
** determines an initial offset into the yy_action array. The lookahead
** value is then added to this initial offset to get an index X into the
** yy_action array. If the aAction[X].lookahead equals the value of the
** of the lookahead input, then the value of the action_number output is
** aAction[X].action. If the lookaheads do not match then the
** default action for the state_number is returned.
**
** All actions associated with a single state_number are first entered
** into aLookahead[] using multiple calls to acttab_action(). Then the
** actions for that single state_number are placed into the aAction[]
** array with a single call to acttab_insert(). The acttab_insert() call
** also resets the aLookahead[] array in preparation for the next
** state number.
*/
typedef struct acttab acttab;
struct acttab {
@ -454,7 +470,10 @@ acttab *acttab_alloc(void){
return p;
}
/* Add a new action to the current transaction set
/* Add a new action to the current transaction set.
**
** This routine is called once for each lookahead for a particular
** state.
*/
void acttab_action(acttab *p, int lookahead, int action){
if( p->nLookahead>=p->nLookaheadAlloc ){
@ -491,7 +510,6 @@ void acttab_action(acttab *p, int lookahead, int action){
*/
int acttab_insert(acttab *p){
int i, j, k, n;
int nActtab; /* Number of slots in the p->aAction[] table */
assert( p->nLookahead>0 );
/* Make sure we have enough space to hold the expanded action table
@ -499,8 +517,7 @@ int acttab_insert(acttab *p){
** must be appended to the current action table
*/
n = p->mxLookahead + 1;
nActtab = p->nAction + n;
if( nActtab >= p->nActionAlloc ){
if( p->nAction + n >= p->nActionAlloc ){
int oldAlloc = p->nActionAlloc;
p->nActionAlloc = p->nAction + n + p->nActionAlloc + 20;
p->aAction = realloc( p->aAction,
@ -515,16 +532,16 @@ int acttab_insert(acttab *p){
}
}
/* Scan the existing action table looking for an offset where we can
** insert the current transaction set. Fall out of the loop when that
** offset is found. In the worst case, we fall out of the loop when
** i reaches nActtab, which means we append the new transaction set.
/* Scan the existing action table looking for an offset that is a
** duplicate of the current transaction set. Fall out of the loop
** if and when the duplicate is found.
**
** i is the index in p->aAction[] where p->mnLookahead is inserted.
*/
for(i=nActtab-1; i>=0; i--){
/* First look for an existing action table entry that can be reused */
for(i=p->nAction-1; i>=0; i--){
if( p->aAction[i].lookahead==p->mnLookahead ){
/* All lookaheads and actions in the aLookahead[] transaction
** must match against the candidate aAction[i] entry. */
if( p->aAction[i].action!=p->mnAction ) continue;
for(j=0; j<p->nLookahead; j++){
k = p->aLookahead[j].lookahead - p->mnLookahead + i;
@ -533,19 +550,30 @@ int acttab_insert(acttab *p){
if( p->aLookahead[j].action!=p->aAction[k].action ) break;
}
if( j<p->nLookahead ) continue;
/* No possible lookahead value that is not in the aLookahead[]
** transaction is allowed to match aAction[i] */
n = 0;
for(j=0; j<p->nAction; j++){
if( p->aAction[j].lookahead<0 ) continue;
if( p->aAction[j].lookahead==j+p->mnLookahead-i ) n++;
}
if( n==p->nLookahead ){
break; /* Same as a prior transaction set */
break; /* An exact match is found at offset i */
}
}
}
/* If no existing offsets exactly match the current transaction, find an
** an empty offset in the aAction[] table in which we can add the
** aLookahead[] transaction.
*/
if( i<0 ){
/* If no reusable entry is found, look for an empty slot */
for(i=0; i<nActtab; i++){
/* Look for holes in the aAction[] table that fit the current
** aLookahead[] transaction. Leave i set to the offset of the hole.
** If no holes are found, i is left at p->nAction, which means the
** transaction will be appended. */
for(i=0; i<p->nActionAlloc - p->mxLookahead; i++){
if( p->aAction[i].lookahead<0 ){
for(j=0; j<p->nLookahead; j++){
k = p->aLookahead[j].lookahead - p->mnLookahead + i;