diff --git a/util/LLgen/lib/rec b/util/LLgen/lib/rec index 0f8a82be3..3d2188d9d 100644 --- a/util/LLgen/lib/rec +++ b/util/LLgen/lib/rec @@ -58,7 +58,8 @@ LLerror(t) { #ifdef LL_NEWMESS if (t == EOFILE) { #ifdef LL_USERHOOK - LLuserhook(EOFILE); + static int lst[] = { EOFILE, 0 }; + LLuserhook(EOFILE, lst); #endif LL_USERHOOK if (LLsymb != EOFILE) { LLmessage(-1); @@ -119,16 +120,43 @@ LLskip() { return LLdoskip(0); } -LLuserhook(exp) +LLuserhook(exp, list) + int *list; { int old = LLsymb; - LL_USERHOOK(exp); + LL_USERHOOK(exp, list); LLread(); return LLsymb != old; } +LLmklist(list) + register int *list; +{ + char Xset[LL_SSIZE]; + register char *p; + register int i; + + for (p = &Xset[0]; p < &Xset[LL_SSIZE]; ) *p++ = 0; + for (i = 0; i < LL_NTERMINALS; i++) { + if (LLtcnt[i] != 0) Xset[i >> 3] |= (1 << (i & 07)); + } + for (i = LL_NSETS - 1; i >= 0; i--) if (LLscnt[i] != 0) { + register char *q = &LLsets[LL_SSIZE * i]; + + p = &Xset[0]; + while (p < &Xset[LL_SSIZE]) *p++ |= *q++; + } + for (i = 0; i < LL_NTERMINALS; i++) { + if (Xset[i >> 3] & (1 << (i & 07))) { + *list++ = LLtok[i]; + } + } + *list = 0; +} + LLdoskip(exp) { int LLx; + int list[LL_NTERMINALS+1]; #endif LL_USERHOOK register int i; int retval; @@ -136,23 +164,34 @@ LLdoskip(exp) { retval = 0; #ifdef LL_USERHOOK - LLx = LLuserhook(exp); + LLmklist(list); + LLx = LLuserhook(exp, list); if (LLx) retval = 1; #endif LL_USERHOOK for (;;) { - if (LLtcnt[LLcsymb] != 0) return retval; + if (LLtcnt[LLcsymb] != 0) { +#ifdef LL_USERHOOK + if (!exp || !LLx || LLsymb == exp) +#endif + return retval; + } LLi = LLcsymb >> 3; LLb = 1 << (LLcsymb & 07); for (i = LL_NSETS - 1; i >= 0; i--) { if (LLscnt[i] != 0) { if (LLsets[LL_SSIZE*i+LLi] & LLb) { +#ifdef LL_USERHOOK + if (!exp || !LLx || LLsymb == exp) +#endif return retval; } } } #ifdef LL_USERHOOK - if (LLx) LLx = LLuserhook(exp); - if (LLx) continue; + if (LLx) { + LLx = LLuserhook(exp, list); + continue; + } #endif LL_USERHOOK LLmessage(0); retval = 1;