remove empty-producing nonterminals
This commit is contained in:
parent
f8a9f58006
commit
2deb5cafce
2 changed files with 18 additions and 8 deletions
|
@ -253,6 +253,10 @@ generate(f) p_file f; {
|
||||||
* of synchronisation with the action file
|
* of synchronisation with the action file
|
||||||
*/
|
*/
|
||||||
while (p->n_count--) getaction(1);
|
while (p->n_count--) getaction(1);
|
||||||
|
if (g_gettype(p->n_rule) == EORULE &&
|
||||||
|
getntparams(p) == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
fprintf(fpars,"L%d_%s (\n",s->o_index,p->n_name);
|
fprintf(fpars,"L%d_%s (\n",s->o_index,p->n_name);
|
||||||
if (p->n_flags & PARAMS) {
|
if (p->n_flags & PARAMS) {
|
||||||
controlline();
|
controlline();
|
||||||
|
@ -487,12 +491,6 @@ rulecode(p,safety,mustscan,mustpop) register p_gram p; {
|
||||||
getntsafe(n) <= SAFESCANDONE)) {
|
getntsafe(n) <= SAFESCANDONE)) {
|
||||||
genpop(findindex(n->n_contains));
|
genpop(findindex(n->n_contains));
|
||||||
}
|
}
|
||||||
if (g_gettype(n->n_rule) == EORULE &&
|
|
||||||
safety <= getntout(n) &&
|
|
||||||
! g_getnpar(p)) {
|
|
||||||
safety = getntout(n);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
fprintf(f,"L%d_%s(\n",g_getcont(p), n->n_name);
|
fprintf(f,"L%d_%s(\n",g_getcont(p), n->n_name);
|
||||||
if (g_getnpar(p)) {
|
if (g_getnpar(p)) {
|
||||||
controlline();
|
controlline();
|
||||||
|
|
|
@ -102,9 +102,21 @@ reachwalk(p) register p_gram p; {
|
||||||
case TERM :
|
case TERM :
|
||||||
reachwalk(g_getterm(p)->t_rule);
|
reachwalk(g_getterm(p)->t_rule);
|
||||||
break;
|
break;
|
||||||
case NONTERM :
|
case NONTERM : {
|
||||||
reachable(&nonterms[g_getcont(p)]);
|
register p_nont n = &nonterms[g_getcont(p)];
|
||||||
|
|
||||||
|
reachable(n);
|
||||||
|
if (g_gettype(n->n_rule) == EORULE &&
|
||||||
|
! g_getnpar(p) && (getntparams(n) == 0)) {
|
||||||
|
register p_gram np = p;
|
||||||
|
do {
|
||||||
|
*np = *(np + 1);
|
||||||
|
np++;
|
||||||
|
} while (g_gettype(np) != EORULE);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case EORULE :
|
case EORULE :
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue