modified generation of token mapping somewhat

This commit is contained in:
ceriel 1988-06-24 11:48:10 +00:00
parent 8bdf3af20c
commit e1f7d20251
3 changed files with 11 additions and 12 deletions

View file

@ -17,7 +17,6 @@ extern int LLsymb;
extern unsigned int LLscnt[]; extern unsigned int LLscnt[];
extern unsigned int LLtcnt[]; extern unsigned int LLtcnt[];
extern int LLcsymb; extern int LLcsymb;
extern int LL_symb;
#define LLsdecr(d) {LL_assert(LLscnt[d] > 0); LLscnt[d]--;} #define LLsdecr(d) {LL_assert(LLscnt[d] > 0); LLscnt[d]--;}
#define LLtdecr(d) {LL_assert(LLtcnt[d] > 0); LLtcnt[d]--;} #define LLtdecr(d) {LL_assert(LLtcnt[d] > 0); LLtcnt[d]--;}

View file

@ -32,8 +32,7 @@ LLscan(t) {
/* /*
* Check if the next symbol is equal to the parameter * Check if the next symbol is equal to the parameter
*/ */
if ((LLsymb = LL_LEXI()) <= 0) LLsymb = EOFILE; if ((LLsymb = LL_LEXI()) == t) {
if (LLsymb == t) {
return; return;
} }
/* /*
@ -44,8 +43,7 @@ LLscan(t) {
LLread() { LLread() {
for (;;) { for (;;) {
if ((LLsymb = LL_LEXI()) <= 0) LLsymb = EOFILE; if ((LLcsymb = LLindex[(LLsymb = LL_LEXI())]) >= 0) return;
if ((LLcsymb = LLindex[LLsymb]) >= 0) return;
LLmessage(0); LLmessage(0);
} }
/* NOTREACHED */ /* NOTREACHED */
@ -54,15 +52,17 @@ LLread() {
LLerror(t) { LLerror(t) {
register int i; register int i;
if (t == EOFILE && LLsymb <= 0) return;
#ifdef LL_NEWMESS #ifdef LL_NEWMESS
if (t == EOFILE) { if (t == EOFILE) {
#ifdef LL_USERHOOK #ifdef LL_USERHOOK
static int lst[] = { EOFILE, 0 }; static int lst[] = { EOFILE, 0 };
LLuserhook(EOFILE, lst); LLuserhook(EOFILE, lst);
#endif LL_USERHOOK #endif LL_USERHOOK
if (LLsymb != EOFILE) { if (LLsymb != EOFILE && LLsymb > 0) {
LLmessage(-1); LLmessage(-1);
while ((LLsymb = LL_LEXI()) > 0) /* nothing */ ; while ((LLsymb = LL_LEXI()) > 0 && LLsymb != EOFILE)
/* nothing */ ;
} }
return; return;
} }
@ -107,7 +107,7 @@ LLnext(n) {
if (n <= 0 && LLsets[(LLcsymb >> 3) - n] & (1 << (LLcsymb & 07))) { if (n <= 0 && LLsets[(LLcsymb >> 3) - n] & (1 << (LLcsymb & 07))) {
retval |= 2; retval |= 2;
} }
else if (LLsymb == n) retval |= 2; else if (n > 0 && LLcsymb == LLindex[n]) retval |= 2;
return retval; return retval;
} }
@ -170,7 +170,7 @@ LLdoskip(exp) {
for (;;) { for (;;) {
if (LLtcnt[LLcsymb] != 0) { if (LLtcnt[LLcsymb] != 0) {
#ifdef LL_USERHOOK #ifdef LL_USERHOOK
if (!exp || !LLx || LLsymb == exp) if (!exp || !LLx || LLcsymb == LLindex[exp])
#endif #endif
return retval; return retval;
} }
@ -180,7 +180,7 @@ LLdoskip(exp) {
if (LLscnt[i] != 0) { if (LLscnt[i] != 0) {
if (LLsets[LL_SSIZE*i+LLi] & LLb) { if (LLsets[LL_SSIZE*i+LLi] & LLb) {
#ifdef LL_USERHOOK #ifdef LL_USERHOOK
if (!exp || !LLx || LLsymb == exp) if (!exp || !LLx || LLcsymb == LLindex[exp])
#endif #endif
return retval; return retval;
} }

View file

@ -208,8 +208,8 @@ genrecovery() {
for (t = tokens; t < maxt; t++) { for (t = tokens; t < maxt; t++) {
index[t->t_tokno] = t - tokens; index[t->t_tokno] = t - tokens;
} }
fputs("static short LLindex[] = {\n",f); fputs("#define LLindex (LL_index+1)\nstatic short LL_index[] = {0,0,\n",f);
for (q = index; q < &index[assval]; q++) { for (q = index+1; q < &index[assval]; q++) {
fprintf(f, "%d,\n", *q); fprintf(f, "%d,\n", *q);
} }
fputs(c_arrend, f); fputs(c_arrend, f);