mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 23:01:59 +00:00
Lemon update 2016-05-23 14:24:31 on branch trunk
— Fix comment typos and improve clarity of presention in Lemon. The output should be identical. (user: drh)
This commit is contained in:
parent
0d67d107ab
commit
64bd551d20
1 changed files with 36 additions and 1 deletions
|
@ -245,6 +245,7 @@ struct action {
|
|||
struct state *stp; /* The new state, if a shift */
|
||||
struct rule *rp; /* The rule, if a reduce */
|
||||
} x;
|
||||
struct symbol *spOpt; /* SHIFTREDUCE optimization to this symbol */
|
||||
struct action *next; /* Next action for this state */
|
||||
struct action *collide; /* Next action with the same hash */
|
||||
};
|
||||
|
@ -435,6 +436,7 @@ void Action_add(
|
|||
*app = newaction;
|
||||
newaction->type = type;
|
||||
newaction->sp = sp;
|
||||
newaction->spOpt = 0;
|
||||
if( type==SHIFT ){
|
||||
newaction->x.stp = (struct state *)arg;
|
||||
}else{
|
||||
|
@ -3160,6 +3162,9 @@ int PrintAction(
|
|||
result = 0;
|
||||
break;
|
||||
}
|
||||
if( result && ap->spOpt ){
|
||||
fprintf(fp," /* because %s==%s */", ap->sp->name, ap->spOpt->name);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -4513,7 +4518,7 @@ void ReportHeader(struct lemon *lemp)
|
|||
void CompressTables(struct lemon *lemp)
|
||||
{
|
||||
struct state *stp;
|
||||
struct action *ap, *ap2;
|
||||
struct action *ap, *ap2, *nextap;
|
||||
struct rule *rp, *rp2, *rbest;
|
||||
int nbest, n;
|
||||
int i;
|
||||
|
@ -4590,6 +4595,36 @@ void CompressTables(struct lemon *lemp)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If a SHIFTREDUCE action specifies a rule that has a single RHS term
|
||||
** (meaning that the SHIFTREDUCE will land back in the state where it
|
||||
** started) and if there is no C-code associated with the reduce action,
|
||||
** then we can go ahead and convert the action to be the same as the
|
||||
** action for the RHS of the rule.
|
||||
*/
|
||||
for(i=0; i<lemp->nstate; i++){
|
||||
stp = lemp->sorted[i];
|
||||
for(ap=stp->ap; ap; ap=nextap){
|
||||
nextap = ap->next;
|
||||
if( ap->type!=SHIFTREDUCE ) continue;
|
||||
rp = ap->x.rp;
|
||||
if( rp->noCode==0 ) continue;
|
||||
if( rp->nrhs!=1 ) continue;
|
||||
#if 1
|
||||
/* Only apply this optimization to non-terminals. It would be OK to
|
||||
** apply it to terminal symbols too, but that makes the parser tables
|
||||
** larger. */
|
||||
if( ap->sp->index<lemp->nterminal ) continue;
|
||||
#endif
|
||||
/* If we reach this point, it means the optimization can be applied */
|
||||
nextap = ap;
|
||||
for(ap2=stp->ap; ap2 && (ap2==ap || ap2->sp!=rp->lhs); ap2=ap2->next){}
|
||||
assert( ap2!=0 );
|
||||
ap->spOpt = ap2->sp;
|
||||
ap->type = ap2->type;
|
||||
ap->x = ap2->x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue