-C Patch\sso\sthe\sthe\scode\scompiles\swith\s-DSQLITE_OMIT_CHECK=1.\s(CVS\s3737)
-D 2007-03-29T00:08:25
+C Lemon\schange:\scompile\sthe\sresulting\sparser\swith\s-DYYSTACKDEPTH=0\sor\sset\nthe\s"%stack_size"\sparameter\sto\s0\sin\sthe\sgrammar\sand\sthe\sparser\sstack\nwill\sbe\sdynamically\sallocated\susing\srealloc()\sand\sfree().\s\sThe\sdefault\nbehavior\sis\sto\shave\sa\sfinite\sdepth\sstack.\s(CVS\s3738)
+D 2007-03-29T01:44:46
F Makefile.in 1fe3d0b46e40fd684e1e61f8e8056cefed16de9f
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F test/where4.test b68496500bff496e83e76ae4ffb493b99064eac6
F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439
-F tool/lemon.c d3dff81e31c459dd18784d024a759b7229f66297
-F tool/lempar.c fdc1672e97f72f72e76553038501da40fec9d251
+F tool/lemon.c 3ac82886bff8096379fa4bfe5ea188e242bbaa47
+F tool/lempar.c 1c08d864e18ac4f146554c2fb76ae1ab751f776f
F tool/memleak.awk 4e7690a51bf3ed757e611273d43fe3f65b510133
F tool/memleak2.awk 9cc20c8e8f3c675efac71ea0721ee6874a1566e8
F tool/memleak3.tcl 7707006ee908cffff210c98158788d85bb3fcdbf
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 53fff7d1f2f829010a2641c7738538b3155da4b2
-R a8b7b84401a648f00168521d709f0ebb
+P 72cea358da4bd38af322f18f2a753171f7decaf8
+R 19096804931fc69bc6361fcf0c3ff22e
U drh
-Z 604fd965906231b9b5400c42a321a29e
+Z 85e0303fabdca8721ceddd77f2f883b6
print_stack_union(out,lemp,&lineno,mhflag);
fprintf(out, "#ifndef YYSTACKDEPTH\n"); lineno++;
if( lemp->stacksize ){
- if( atoi(lemp->stacksize)<=0 ){
- ErrorMsg(lemp->filename,0,
-"Illegal stack size: [%s]. The stack size should be an integer constant.",
- lemp->stacksize);
- lemp->errorcnt++;
- lemp->stacksize = "100";
- }
fprintf(out,"#define YYSTACKDEPTH %s\n",lemp->stacksize); lineno++;
}else{
fprintf(out,"#define YYSTACKDEPTH 100\n"); lineno++;
** This is typically a union of many types, one of
** which is ParseTOKENTYPE. The entry in the union
** for base tokens is called "yy0".
-** YYSTACKDEPTH is the maximum depth of the parser's stack.
+** YYSTACKDEPTH is the maximum depth of the parser's stack. If
+** zero the stack is dynamically sized using realloc()
** ParseARG_SDECL A static variable declaration for the %extra_argument
** ParseARG_PDECL A parameter declaration for the %extra_argument
** ParseARG_STORE Code to store %extra_argument into yypParser
int yyidx; /* Index of top element in stack */
int yyerrcnt; /* Shifts left before out of the error */
ParseARG_SDECL /* A place to hold %extra_argument */
+#if YYSTACKDEPTH<=0
+ int yystksz; /* Current side of the stack */
+ yyStackEntry *yystack; /* The parser's stack */
+#else
yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
+#endif
};
typedef struct yyParser yyParser;
#endif
}
+#if YYSTACKDEPTH<=0
+/*
+** Try to increase the size of the parser stack.
+*/
+static void yyGrowStack(yyParser *p){
+ int newSize;
+ yyStackEntry *pNew;
+
+ newSize = p->yystksz*2 + 100;
+ pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
+ if( pNew ){
+ p->yystack = pNew;
+ p->yystksz = newSize;
+#ifndef NDEBUG
+ if( yyTraceFILE ){
+ fprintf(yyTraceFILE,"%sStack grows to %d entries!\n",
+ yyTracePrompt, p->yystksz);
+ }
+#endif
+ }
+}
+#endif
+
/*
** This function allocates a new parser.
** The only argument is a pointer to a function which works like
pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) );
if( pParser ){
pParser->yyidx = -1;
+#if YYSTACKDEPTH<=0
+ yyGrowStack(pParser);
+#endif
}
return pParser;
}
yyParser *pParser = (yyParser*)p;
if( pParser==0 ) return;
while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser);
+#if YYSTACKDEPTH<=0
+ free(pParser->yystack);
+#endif
(*freeProc)((void*)pParser);
}
}
}
+/*
+** The following routine is called if the stack overflows.
+*/
+static void yyStackOverflow(yyParser *yypParser){
+ ParseARG_FETCH;
+ yypParser->yyidx--;
+#ifndef NDEBUG
+ if( yyTraceFILE ){
+ fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
+ }
+#endif
+ while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
+ /* Here code is inserted which will execute if the parser
+ ** stack every overflows */
+%%
+ ParseARG_STORE; /* Suppress warning about unused %extra_argument var */
+}
+
/*
** Perform a shift action.
*/
){
yyStackEntry *yytos;
yypParser->yyidx++;
+#if YYSTACKDEPTH>0
if( yypParser->yyidx>=YYSTACKDEPTH ){
- ParseARG_FETCH;
- yypParser->yyidx--;
-#ifndef NDEBUG
- if( yyTraceFILE ){
- fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
- }
-#endif
- while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
- /* Here code is inserted which will execute if the parser
- ** stack every overflows */
-%%
- ParseARG_STORE; /* Suppress warning about unused %extra_argument var */
- return;
+ yyStackOverflow(yypParser);
+ return;
}
+#else
+ if( yypParser->yyidx>=yypParser->yystksz ){
+ yyGrowStack(yypParser);
+ if( yypParser->yyidx>=yypParser->yystksz ){
+ yyStackOverflow(yypParser);
+ return;
+ }
+ }
+#endif
yytos = &yypParser->yystack[yypParser->yyidx];
yytos->stateno = yyNewState;
yytos->major = yyMajor;
/* (re)initialize the parser, if necessary */
yypParser = (yyParser*)yyp;
if( yypParser->yyidx<0 ){
- /* if( yymajor==0 ) return; // not sure why this was here... */
+ if( yypParser->yystksz <=0 ){
+ yyStackOverflow(yypParser);
+ return;
+ }
yypParser->yyidx = 0;
yypParser->yyerrcnt = -1;
yypParser->yystack[0].stateno = 0;