mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Introduce the concept of "weak fallback" in the parser. A weak fallback
only occurs if a syntax error would result otherwise. FossilOrigin-Name: c41d7079fb63831bd2f009b64cbf5a423e8119e6b841bfd9bd5a2d85fba3b142
This commit is contained in:
@ -90,6 +90,7 @@
|
||||
/************* Begin control #defines *****************************************/
|
||||
%%
|
||||
/************* End control #defines *******************************************/
|
||||
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
|
||||
|
||||
/* Define the yytestcase() macro to be a no-op if is not already defined
|
||||
** otherwise.
|
||||
@ -172,7 +173,7 @@
|
||||
** it appears.
|
||||
*/
|
||||
#ifdef YYFALLBACK
|
||||
static const YYCODETYPE yyFallback[] = {
|
||||
static const int yyFallback[] = {
|
||||
%%
|
||||
};
|
||||
#endif /* YYFALLBACK */
|
||||
@ -519,24 +520,34 @@ static YYACTIONTYPE yy_find_shift_action(
|
||||
do{
|
||||
i = yy_shift_ofst[stateno];
|
||||
assert( i>=0 );
|
||||
assert( i+YYNTOKEN<=(int)sizeof(yy_lookahead)/sizeof(yy_lookahead[0]) );
|
||||
/*assert( i+YYNTOKEN<=YY_NLOOKAHEAD );*/
|
||||
assert( iLookAhead!=YYNOCODE );
|
||||
assert( iLookAhead < YYNTOKEN );
|
||||
i += iLookAhead;
|
||||
if( yy_lookahead[i]!=iLookAhead ){
|
||||
if( i>=YY_NLOOKAHEAD || yy_lookahead[i]!=iLookAhead
|
||||
){
|
||||
#ifdef YYFALLBACK
|
||||
YYCODETYPE iFallback; /* Fallback token */
|
||||
int iFallback; /* Fallback token */
|
||||
if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
|
||||
&& (iFallback = yyFallback[iLookAhead])!=0 ){
|
||||
#ifndef NDEBUG
|
||||
if( yyTraceFILE ){
|
||||
fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
|
||||
yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
|
||||
&& (iFallback = yyFallback[iLookAhead])!=0
|
||||
){
|
||||
if( iFallback<0 && yy_default[stateno]==YY_ERROR_ACTION ){
|
||||
/* A weak fallback only happens if current lookahead is a
|
||||
** syntax error */
|
||||
iFallback = -iFallback;
|
||||
}
|
||||
if( iFallback>0 ){
|
||||
/* A strong fallback happens regardless */
|
||||
#ifndef NDEBUG
|
||||
if( yyTraceFILE ){
|
||||
fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
|
||||
yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
|
||||
}
|
||||
#endif
|
||||
assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */
|
||||
iLookAhead = iFallback;
|
||||
continue;
|
||||
assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */
|
||||
iLookAhead = iFallback;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef YYWILDCARD
|
||||
|
Reference in New Issue
Block a user