From 451c0d6679cf6ba8b6c26a7d24a91b6616b470e8 Mon Sep 17 00:00:00 2001 From: ceriel Date: Tue, 17 Mar 1987 22:41:18 +0000 Subject: [PATCH] improved userhook handling, This required some changes in the semantics of LLnext and LLskip. --- util/LLgen/lib/rec | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/util/LLgen/lib/rec b/util/LLgen/lib/rec index 0f666d1ff..0f8a82be3 100644 --- a/util/LLgen/lib/rec +++ b/util/LLgen/lib/rec @@ -92,13 +92,29 @@ LLfirst(x, d) { # endif LLnext(n) { - - if (LLskip()) /* nothing */; - if (n <= 0) return (LLsets[(LLcsymb >> 3) - n] & (1 << (LLcsymb & 07))); - return LLsymb == n; + /* returns: 0 if the current symbol is'nt skipped, and it + is'nt a member of "n", + 1 if we have a new symbol, but it is'nt a member, + 2 if the current symbol is a member, + and 3 if we have a new symbol and it is a member. + So, the low order bit indicates wether we have a new symbol, + and the next bit indicates wether it is a member of "n". + */ + + int retval = 0; + + if (LLskip()) retval = 1; + if (n <= 0 && LLsets[(LLcsymb >> 3) - n] & (1 << (LLcsymb & 07))) { + retval |= 2; + } + else if (LLsymb == n) retval |= 2; + return retval; } LLskip() { + /* returns 0 if the current symbol is'nt skipped, and + 1 if it is, t.i., we have a new symbol + */ #ifdef LL_USERHOOK return LLdoskip(0); } @@ -112,16 +128,18 @@ LLuserhook(exp) } LLdoskip(exp) { + int LLx; #endif LL_USERHOOK register int i; int retval; int LLi, LLb; retval = 0; - for (;;) { #ifdef LL_USERHOOK - if (LLuserhook(exp)) continue; + LLx = LLuserhook(exp); + if (LLx) retval = 1; #endif LL_USERHOOK + for (;;) { if (LLtcnt[LLcsymb] != 0) return retval; LLi = LLcsymb >> 3; LLb = 1 << (LLcsymb & 07); @@ -132,6 +150,10 @@ LLdoskip(exp) { } } } +#ifdef LL_USERHOOK + if (LLx) LLx = LLuserhook(exp); + if (LLx) continue; +#endif LL_USERHOOK LLmessage(0); retval = 1; LLread(); -- 2.34.1