mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-01-18 15:11:46 +00:00
Lemon update 2015-11-09 15:06:26 on branch trunk
- Avoid recursion in the yy_find_shift_action() routine of the Lemon-generated parser, so that routine can be inlined, for a size reduction and performance increase. (user: drh)
This commit is contained in:
parent
bcdef59c3c
commit
59b14415ff
1 changed files with 51 additions and 41 deletions
|
@ -398,55 +398,60 @@ static int yy_find_shift_action(
|
||||||
){
|
){
|
||||||
int i;
|
int i;
|
||||||
int stateno = pParser->yystack[pParser->yyidx].stateno;
|
int stateno = pParser->yystack[pParser->yyidx].stateno;
|
||||||
|
|
||||||
if( stateno>=YY_MIN_REDUCE ) return stateno;
|
if( stateno>=YY_MIN_REDUCE ) return stateno;
|
||||||
assert( stateno <= YY_SHIFT_COUNT );
|
assert( stateno <= YY_SHIFT_COUNT );
|
||||||
i = yy_shift_ofst[stateno];
|
do{
|
||||||
if( i==YY_SHIFT_USE_DFLT ) return yy_default[stateno];
|
i = yy_shift_ofst[stateno];
|
||||||
assert( iLookAhead!=YYNOCODE );
|
if( i==YY_SHIFT_USE_DFLT ) return yy_default[stateno];
|
||||||
i += iLookAhead;
|
assert( iLookAhead!=YYNOCODE );
|
||||||
if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
|
i += iLookAhead;
|
||||||
if( iLookAhead>0 ){
|
if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
|
||||||
|
if( iLookAhead>0 ){
|
||||||
#ifdef YYFALLBACK
|
#ifdef YYFALLBACK
|
||||||
YYCODETYPE iFallback; /* Fallback token */
|
YYCODETYPE iFallback; /* Fallback token */
|
||||||
if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
|
if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
|
||||||
&& (iFallback = yyFallback[iLookAhead])!=0 ){
|
&& (iFallback = yyFallback[iLookAhead])!=0 ){
|
||||||
#ifndef NDEBUG
|
|
||||||
if( yyTraceFILE ){
|
|
||||||
fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
|
|
||||||
yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return yy_find_shift_action(pParser, iFallback);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef YYWILDCARD
|
|
||||||
{
|
|
||||||
int j = i - iLookAhead + YYWILDCARD;
|
|
||||||
if(
|
|
||||||
#if YY_SHIFT_MIN+YYWILDCARD<0
|
|
||||||
j>=0 &&
|
|
||||||
#endif
|
|
||||||
#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
|
|
||||||
j<YY_ACTTAB_COUNT &&
|
|
||||||
#endif
|
|
||||||
yy_lookahead[j]==YYWILDCARD
|
|
||||||
){
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if( yyTraceFILE ){
|
if( yyTraceFILE ){
|
||||||
fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
|
fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
|
||||||
yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]);
|
yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */
|
||||||
|
iLookAhead = iFallback;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef YYWILDCARD
|
||||||
|
{
|
||||||
|
int j = i - iLookAhead + YYWILDCARD;
|
||||||
|
if(
|
||||||
|
#if YY_SHIFT_MIN+YYWILDCARD<0
|
||||||
|
j>=0 &&
|
||||||
|
#endif
|
||||||
|
#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
|
||||||
|
j<YY_ACTTAB_COUNT &&
|
||||||
|
#endif
|
||||||
|
yy_lookahead[j]==YYWILDCARD
|
||||||
|
){
|
||||||
|
#ifndef NDEBUG
|
||||||
|
if( yyTraceFILE ){
|
||||||
|
fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
|
||||||
|
yyTracePrompt, yyTokenName[iLookAhead],
|
||||||
|
yyTokenName[YYWILDCARD]);
|
||||||
|
}
|
||||||
|
#endif /* NDEBUG */
|
||||||
|
return yy_action[j];
|
||||||
}
|
}
|
||||||
#endif /* NDEBUG */
|
|
||||||
return yy_action[j];
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif /* YYWILDCARD */
|
#endif /* YYWILDCARD */
|
||||||
|
}
|
||||||
|
return yy_default[stateno];
|
||||||
|
}else{
|
||||||
|
return yy_action[i];
|
||||||
}
|
}
|
||||||
return yy_default[stateno];
|
}while(1);
|
||||||
}else{
|
|
||||||
return yy_action[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -625,6 +630,7 @@ static void yy_reduce(
|
||||||
*/
|
*/
|
||||||
%%
|
%%
|
||||||
};
|
};
|
||||||
|
assert( yyruleno>=0 && yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
|
||||||
yygoto = yyRuleInfo[yyruleno].lhs;
|
yygoto = yyRuleInfo[yyruleno].lhs;
|
||||||
yysize = yyRuleInfo[yyruleno].nrhs;
|
yysize = yyRuleInfo[yyruleno].nrhs;
|
||||||
yypParser->yyidx -= yysize;
|
yypParser->yyidx -= yysize;
|
||||||
|
@ -732,7 +738,9 @@ void Parse(
|
||||||
){
|
){
|
||||||
YYMINORTYPE yyminorunion;
|
YYMINORTYPE yyminorunion;
|
||||||
int yyact; /* The parser action. */
|
int yyact; /* The parser action. */
|
||||||
|
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
|
||||||
int yyendofinput; /* True if we are at the end of input */
|
int yyendofinput; /* True if we are at the end of input */
|
||||||
|
#endif
|
||||||
#ifdef YYERRORSYMBOL
|
#ifdef YYERRORSYMBOL
|
||||||
int yyerrorhit = 0; /* True if yymajor has invoked an error */
|
int yyerrorhit = 0; /* True if yymajor has invoked an error */
|
||||||
#endif
|
#endif
|
||||||
|
@ -755,7 +763,9 @@ void Parse(
|
||||||
yypParser->yystack[0].major = 0;
|
yypParser->yystack[0].major = 0;
|
||||||
}
|
}
|
||||||
yyminorunion.yy0 = yyminor;
|
yyminorunion.yy0 = yyminor;
|
||||||
|
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
|
||||||
yyendofinput = (yymajor==0);
|
yyendofinput = (yymajor==0);
|
||||||
|
#endif
|
||||||
ParseARG_STORE;
|
ParseARG_STORE;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
|
Loading…
Reference in a new issue