From 74b078c3f1f0240491797284cd5594b6bcd91151 Mon Sep 17 00:00:00 2001 From: ceriel Date: Thu, 5 Feb 1987 19:14:55 +0000 Subject: [PATCH] just for fun: do not call empty rules. --- util/LLgen/src/gencode.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/util/LLgen/src/gencode.c b/util/LLgen/src/gencode.c index 1d17f08cc..f78ff4d19 100644 --- a/util/LLgen/src/gencode.c +++ b/util/LLgen/src/gencode.c @@ -458,16 +458,21 @@ rulecode(p,safety,mustscan,mustpop) register p_gram p; { safety = NOSCANDONE; break; } case NONTERM : { - register p_nont n; + register p_nont n = &nonterms[g_getnont(p)]; - n = &nonterms[g_getnont(p)]; if (safety == NOSCANDONE && - getntsafe(n) < NOSCANDONE) fputs(c_read, f); + getntsafe(n) < NOSCANDONE) { + safety = getntsafe(n); + fputs(c_read, f); + } if (toplevel == 0 && (g_gettype(n->n_rule) != ALTERNATION || getntsafe(n) <= SAFESCANDONE)) { genpop(findindex(n->n_contains)); } + if (g_gettype(n->n_rule) == EORULE && + safety == getntout(n) && + ! g_getnpar(p)) break; fprintf(f,"L%d_%s(\n",g_getnont(p), n->n_name); if (g_getnpar(p)) { controlline();