mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 06:42:12 +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;
|
||||
int i;
|
||||
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 */
|
||||
char lhsused = 0; /* True if the LHS element has been used */
|
||||
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 ){
|
||||
append_str(zOvwrt,0,0,0,0);
|
||||
cp += lemonStrlen(zOvwrt)-1;
|
||||
dontUseRhs0 = 1;
|
||||
continue;
|
||||
}
|
||||
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{
|
||||
for(i=0; i<rp->nrhs; i++){
|
||||
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
|
||||
** the token number of X, not the value of X */
|
||||
append_str("yymsp[%d].major",-1,i-rp->nrhs+1,0,0);
|
||||
|
|
|
@ -646,14 +646,14 @@ static void yy_reduce(
|
|||
}
|
||||
#endif
|
||||
#if YYSTACKDEPTH>0
|
||||
if( yypParser->yyidx>=YYSTACKDEPTH ){
|
||||
if( yypParser->yyidx>=YYSTACKDEPTH-1 ){
|
||||
yyStackOverflow(yypParser);
|
||||
return;
|
||||
}
|
||||
#else
|
||||
if( yypParser->yyidx>=yypParser->yystksz ){
|
||||
if( yypParser->yyidx>=yypParser->yystksz-1 ){
|
||||
yyGrowStack(yypParser);
|
||||
if( yypParser->yyidx>=yypParser->yystksz ){
|
||||
if( yypParser->yyidx>=yypParser->yystksz-1 ){
|
||||
yyStackOverflow(yypParser);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue