Lemon update 2016-02-16 01:01:43 on branch trunk

- Improve the Lemon parser template (lempar.c) so that it avoids unnecessary work when the grammer defines YYNOERRORRECOVERY (as SQLite does). Slightly smaller and faster code results. (user: drh)
This commit is contained in:
Randy Heit 2016-03-20 12:21:41 -05:00
parent be870502fd
commit 7306279a87

View file

@ -221,7 +221,9 @@ struct yyParser {
#ifdef YYTRACKMAXSTACKDEPTH #ifdef YYTRACKMAXSTACKDEPTH
int yyidxMax; /* Maximum value of yyidx */ int yyidxMax; /* Maximum value of yyidx */
#endif #endif
#ifndef YYNOERRORRECOVERY
int yyerrcnt; /* Shifts left before out of the error */ int yyerrcnt; /* Shifts left before out of the error */
#endif
ParseARG_SDECL /* A place to hold %extra_argument */ ParseARG_SDECL /* A place to hold %extra_argument */
#if YYSTACKDEPTH<=0 #if YYSTACKDEPTH<=0
int yystksz; /* Current side of the stack */ int yystksz; /* Current side of the stack */
@ -784,7 +786,9 @@ void Parse(
} }
#endif #endif
yypParser->yyidx = 0; yypParser->yyidx = 0;
#ifndef YYNOERRORRECOVERY
yypParser->yyerrcnt = -1; yypParser->yyerrcnt = -1;
#endif
yypParser->yystack[0].stateno = 0; yypParser->yystack[0].stateno = 0;
yypParser->yystack[0].major = 0; yypParser->yystack[0].major = 0;
#ifndef NDEBUG #ifndef NDEBUG
@ -811,7 +815,9 @@ void Parse(
if( yyact <= YY_MAX_SHIFTREDUCE ){ if( yyact <= YY_MAX_SHIFTREDUCE ){
if( yyact > YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; if( yyact > YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
yy_shift(yypParser,yyact,yymajor,&yyminorunion); yy_shift(yypParser,yyact,yymajor,&yyminorunion);
#ifndef YYNOERRORRECOVERY
yypParser->yyerrcnt--; yypParser->yyerrcnt--;
#endif
yymajor = YYNOCODE; yymajor = YYNOCODE;
}else if( yyact <= YY_MAX_REDUCE ){ }else if( yyact <= YY_MAX_REDUCE ){
yy_reduce(yypParser,yyact-YY_MIN_REDUCE); yy_reduce(yypParser,yyact-YY_MIN_REDUCE);