|
|
|
@ -118,7 +118,7 @@ int SetUnion(/* char *A,char *B */); /* A <- A U B, thru element N */
|
|
|
|
|
** Principal data structures for the LEMON parser generator.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
typedef enum {B_FALSE=0, B_TRUE} Boolean;
|
|
|
|
|
typedef enum {Bo_FALSE=0, Bo_TRUE} Boolean;
|
|
|
|
|
|
|
|
|
|
/* Symbols (terminals and nonterminals) of the grammar are stored
|
|
|
|
|
** in the following: */
|
|
|
|
@ -618,7 +618,7 @@ struct lemon *lemp;
|
|
|
|
|
int progress;
|
|
|
|
|
|
|
|
|
|
for(i=0; i<lemp->nsymbol; i++){
|
|
|
|
|
lemp->symbols[i]->lambda = B_FALSE;
|
|
|
|
|
lemp->symbols[i]->lambda = Bo_FALSE;
|
|
|
|
|
}
|
|
|
|
|
for(i=lemp->nterminal; i<lemp->nsymbol; i++){
|
|
|
|
|
lemp->symbols[i]->firstset = SetNew();
|
|
|
|
@ -630,10 +630,10 @@ struct lemon *lemp;
|
|
|
|
|
for(rp=lemp->rule; rp; rp=rp->next){
|
|
|
|
|
if( rp->lhs->lambda ) continue;
|
|
|
|
|
for(i=0; i<rp->nrhs; i++){
|
|
|
|
|
if( rp->rhs[i]->lambda==B_FALSE ) break;
|
|
|
|
|
if( rp->rhs[i]->lambda==Bo_FALSE ) break;
|
|
|
|
|
}
|
|
|
|
|
if( i==rp->nrhs ){
|
|
|
|
|
rp->lhs->lambda = B_TRUE;
|
|
|
|
|
rp->lhs->lambda = Bo_TRUE;
|
|
|
|
|
progress = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -651,10 +651,10 @@ struct lemon *lemp;
|
|
|
|
|
progress += SetAdd(s1->firstset,s2->index);
|
|
|
|
|
break;
|
|
|
|
|
}else if( s1==s2 ){
|
|
|
|
|
if( s1->lambda==B_FALSE ) break;
|
|
|
|
|
if( s1->lambda==Bo_FALSE ) break;
|
|
|
|
|
}else{
|
|
|
|
|
progress += SetUnion(s1->firstset,s2->firstset);
|
|
|
|
|
if( s2->lambda==B_FALSE ) break;
|
|
|
|
|
if( s2->lambda==Bo_FALSE ) break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -949,11 +949,11 @@ struct lemon *lemp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Report an error for each rule that can never be reduced. */
|
|
|
|
|
for(rp=lemp->rule; rp; rp=rp->next) rp->canReduce = B_FALSE;
|
|
|
|
|
for(rp=lemp->rule; rp; rp=rp->next) rp->canReduce = Bo_FALSE;
|
|
|
|
|
for(i=0; i<lemp->nstate; i++){
|
|
|
|
|
struct action *ap;
|
|
|
|
|
for(ap=lemp->sorted[i]->ap; ap; ap=ap->next){
|
|
|
|
|
if( ap->type==REDUCE ) ap->x.rp->canReduce = B_TRUE;
|
|
|
|
|
if( ap->type==REDUCE ) ap->x.rp->canReduce = Bo_TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for(rp=lemp->rule; rp; rp=rp->next){
|
|
|
|
@ -1177,7 +1177,7 @@ struct lemon *lemp;
|
|
|
|
|
break;
|
|
|
|
|
}else{
|
|
|
|
|
SetUnion(newcfp->fws,xsp->firstset);
|
|
|
|
|
if( xsp->lambda==B_FALSE ) break;
|
|
|
|
|
if( xsp->lambda==Bo_FALSE ) break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if( i==rp->nrhs ) Plink_add(&cfp->fplp,newcfp);
|
|
|
|
@ -3887,7 +3887,7 @@ char *x;
|
|
|
|
|
sp->prec = -1;
|
|
|
|
|
sp->assoc = UNK;
|
|
|
|
|
sp->firstset = 0;
|
|
|
|
|
sp->lambda = B_FALSE;
|
|
|
|
|
sp->lambda = Bo_FALSE;
|
|
|
|
|
sp->destructor = 0;
|
|
|
|
|
sp->datatype = 0;
|
|
|
|
|
Symbol_insert(sp,sp->name);
|
|
|
|
|