mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-14 00:21:34 +00:00
Lemon update 2016-02-17 12:34:03 on branch parser-performance
- More agressive use of /*A-overwrites-X*/ in the parser. Fix an off-by-one error in parser stack overflow detection. (user: drh)
This commit is contained in:
parent
25972d79a7
commit
4a24f7adcf
2 changed files with 11 additions and 4 deletions
|
@ -3412,6 +3412,7 @@ PRIVATE int translate_code(struct lemon *lemp, struct rule *rp){
|
||||||
char *cp, *xp;
|
char *cp, *xp;
|
||||||
int i;
|
int i;
|
||||||
int rc = 0; /* True if yylhsminor is used */
|
int rc = 0; /* True if yylhsminor is used */
|
||||||
|
int dontUseRhs0 = 0; /* If true, use of left-most RHS label is illegal */
|
||||||
const char *zSkip = 0; /* The zOvwrt comment within rp->code, or NULL */
|
const char *zSkip = 0; /* The zOvwrt comment within rp->code, or NULL */
|
||||||
char lhsused = 0; /* True if the LHS element has been used */
|
char lhsused = 0; /* True if the LHS element has been used */
|
||||||
char lhsdirect; /* True if LHS writes directly into stack */
|
char lhsdirect; /* True if LHS writes directly into stack */
|
||||||
|
@ -3482,6 +3483,7 @@ PRIVATE int translate_code(struct lemon *lemp, struct rule *rp){
|
||||||
if( cp==zSkip ){
|
if( cp==zSkip ){
|
||||||
append_str(zOvwrt,0,0,0,0);
|
append_str(zOvwrt,0,0,0,0);
|
||||||
cp += lemonStrlen(zOvwrt)-1;
|
cp += lemonStrlen(zOvwrt)-1;
|
||||||
|
dontUseRhs0 = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if( ISALPHA(*cp) && (cp==rp->code || (!ISALNUM(cp[-1]) && cp[-1]!='_')) ){
|
if( ISALPHA(*cp) && (cp==rp->code || (!ISALNUM(cp[-1]) && cp[-1]!='_')) ){
|
||||||
|
@ -3496,7 +3498,12 @@ PRIVATE int translate_code(struct lemon *lemp, struct rule *rp){
|
||||||
}else{
|
}else{
|
||||||
for(i=0; i<rp->nrhs; i++){
|
for(i=0; i<rp->nrhs; i++){
|
||||||
if( rp->rhsalias[i] && strcmp(cp,rp->rhsalias[i])==0 ){
|
if( rp->rhsalias[i] && strcmp(cp,rp->rhsalias[i])==0 ){
|
||||||
if( cp!=rp->code && cp[-1]=='@' ){
|
if( i==0 && dontUseRhs0 ){
|
||||||
|
ErrorMsg(lemp->filename,rp->ruleline,
|
||||||
|
"Label %s used after '%s'.",
|
||||||
|
rp->rhsalias[0], zOvwrt);
|
||||||
|
lemp->errorcnt++;
|
||||||
|
}else if( cp!=rp->code && cp[-1]=='@' ){
|
||||||
/* If the argument is of the form @X then substituted
|
/* If the argument is of the form @X then substituted
|
||||||
** the token number of X, not the value of X */
|
** the token number of X, not the value of X */
|
||||||
append_str("yymsp[%d].major",-1,i-rp->nrhs+1,0,0);
|
append_str("yymsp[%d].major",-1,i-rp->nrhs+1,0,0);
|
||||||
|
|
|
@ -646,14 +646,14 @@ static void yy_reduce(
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if YYSTACKDEPTH>0
|
#if YYSTACKDEPTH>0
|
||||||
if( yypParser->yyidx>=YYSTACKDEPTH ){
|
if( yypParser->yyidx>=YYSTACKDEPTH-1 ){
|
||||||
yyStackOverflow(yypParser);
|
yyStackOverflow(yypParser);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if( yypParser->yyidx>=yypParser->yystksz ){
|
if( yypParser->yyidx>=yypParser->yystksz-1 ){
|
||||||
yyGrowStack(yypParser);
|
yyGrowStack(yypParser);
|
||||||
if( yypParser->yyidx>=yypParser->yystksz ){
|
if( yypParser->yyidx>=yypParser->yystksz-1 ){
|
||||||
yyStackOverflow(yypParser);
|
yyStackOverflow(yypParser);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue