1 /* LLgen generated code from source . */
4 #if __STDC__ || __cplusplus
7 #define LL_LEXI scanner
8 /* $Id: incl,v 2.13 1997/02/21 15:44:09 ceriel Exp $ */
12 #define LL_assert(x) assert(x)
14 #define LL_assert(x) /* nothing */
19 #define LL_SAFE(x) /* Nothing */
20 #define LL_SSCANDONE(x) if (LLsymb != x) LLsafeerror(x)
21 #define LL_SCANDONE(x) if (LLsymb != x) LLerror(x)
22 #define LL_NOSCANDONE(x) LLscan(x)
24 #define LLscan(x) if ((LLsymb = LL_LEXI()) != x) LLerror(x)
27 extern unsigned int LLscnt[];
28 extern unsigned int LLtcnt[];
32 extern int LLstartsymb;
35 #define LLsdecr(d) {LL_assert(LLscnt[d] > 0); LLscnt[d]--;}
36 #define LLtdecr(d) {LL_assert(LLtcnt[d] > 0); LLtcnt[d]--;}
37 #define LLsincr(d) LLscnt[d]++
38 #define LLtincr(d) LLtcnt[d]++
41 extern int LL_LEXI(void);
42 extern void LLread(void);
43 extern int LLskip(void);
44 extern int LLnext(int);
45 extern void LLerror(int);
46 extern void LLsafeerror(int);
47 extern void LLnewlevel(unsigned int *);
48 extern void LLoldlevel(unsigned int *);
50 extern void LLscan(int);
53 extern int LLfirst(int, int);
56 extern void LLnc_recover(void);
58 #else /* not LL_ANSI_C */
73 extern LLnc_recover();
75 #endif /* not LL_ANSI_C */
78 #define LL_NTERMINALS 32
88 unsigned int s[LL_NTERMINALS+LL_NSETS+2];
95 static char LLsets[] = {
96 '\204','\343','\1','\0',
97 '\234','\4','\176','\354',
99 '\234','\0','\60','\350',
100 '\10','\0','\0','\340',
101 '\124','\0','\0','\0',
103 #define LLindex (LL_index+1)
104 static short LL_index[] = {0,0,
386 * Some grammar independent code.
387 * This file is copied into Lpars.c.
391 static char *rcsid = "$Id: rec,v 2.24 1998/11/10 14:26:06 ceriel Exp $";
394 unsigned int LLtcnt[LL_NTERMINALS];
395 unsigned int LLscnt[LL_NSETS];
401 static int fake_eof = 0;
405 #define LL_VOIDCST (void)
412 static int LLdoskip(int);
413 static int LLuserhook(int, int*);
415 static int LLdoskip();
416 static int LLuserhook();
429 * Check if the next symbol is equal to the parameter
433 /* See if the error recovery has eaten an eof */
444 if ((LLsymb = LL_LEXI()) == t) {
448 /* Check if a previous parser has 'crashed', in that
449 * case continue with non-correcting parser
451 if (err_seen && !nc_done) {
454 /* Remember that the error recovery has eaten an eof */
466 * If we come here, an error has been detected
479 /* Again, check if another parser has crashed,
480 * in that case intercept and go to the
481 * non-correcting parser
484 if (err_seen && !nc_done) {
487 /* Pretend we read end of file */
489 LLcsymb = LLindex[EOFILE];
496 LLcsymb = LLindex[EOFILE];
503 if ((LLcsymb = LLindex[(LLsymb = LL_LEXI())]) >= 0) return;
518 if (t == EOFILE && LLsymb <= 0) return;
522 static int lst[] = { EOFILE, 0 };
523 LL_VOIDCST LLuserhook(EOFILE, lst);
524 #endif /* LL_USERHOOK */
525 if (LLsymb != EOFILE && LLsymb > 0) {
527 while ((LLsymb = LL_LEXI()) > 0 && LLsymb != EOFILE)
535 if ((!nc_done) && (LLsymb > 0) && (LLsymb != EOFILE)) {
543 if ((LLcsymb = LLindex[LLsymb]) < 0) {
550 LL_VOIDCST LLdoskip(t);
557 /* A little kludge here; when using non-correcting recovery
558 * it can happen that a program is correct but incomplete.
559 * Here, we test this, and make sure the appropriate
560 * message is generated
568 /* Not really, but to prevent more than 1 error message */
577 void LLsafeerror(int t)
583 if (t == EOFILE && LLsymb <= 0) return;
587 static int lst[] = { EOFILE, 0 };
588 LL_VOIDCST LLuserhook(EOFILE, lst);
589 #endif /* LL_USERHOOK */
590 if (LLsymb != EOFILE && LLsymb > 0) {
592 while ((LLsymb = LL_LEXI()) > 0 && LLsymb != EOFILE)
599 if ((!nc_done) && (LLsymb > 0) && (LLsymb != EOFILE)) {
605 /* A little kludge here; when using non-correcting recovery
606 * it can happen that a program is correct but incomplete.
607 * Here, we test this, and make sure the appropriate
608 * message is generated
616 /* Not really, but to prevent more than 1 error message */
625 int LLfirst(int x, int d) {
631 return (i = LLindex[x]) >= 0 &&
632 (LLsets[d + (i >> 3)] & (1 << (i & 07)));
643 /* returns: 0 if the current symbol is'nt skipped, and it
644 is'nt a member of "n",
645 1 if we have a new symbol, but it is'nt a member,
646 2 if the current symbol is a member,
647 and 3 if we have a new symbol and it is a member.
648 So, the low order bit indicates wether we have a new symbol,
649 and the next bit indicates wether it is a member of "n".
654 if (LLskip()) retval = 1;
655 if (n <= 0 && LLsets[(LLcsymb >> 3) - n] & (1 << (LLcsymb & 07))) {
658 else if (n > 0 && LLcsymb == LLindex[n]) retval |= 2;
667 /* returns 0 if the current symbol is'nt skipped, and
668 1 if it is, t.i., we have a new symbol
675 extern void LL_USERHOOK(int, int *);
676 static int LLuserhook(int e, int *list)
678 static int LLuserhook(e, list)
684 LL_USERHOOK(e, list);
686 return LLsymb != old;
690 static void LLmklist(register int *list)
692 static LLmklist(list)
700 for (p = &Xset[0]; p < &Xset[LL_SSIZE]; ) *p++ = 0;
701 for (i = 0; i < LL_NTERMINALS; i++) {
702 if (LLtcnt[i] != 0) Xset[i >> 3] |= (1 << (i & 07));
704 for (i = LL_NSETS - 1; i >= 0; i--) if (LLscnt[i] != 0) {
705 register char *q = &LLsets[LL_SSIZE * i];
708 while (p < &Xset[LL_SSIZE]) *p++ |= *q++;
710 for (i = 0; i < LL_NTERMINALS; i++) {
711 if (Xset[i >> 3] & (1 << (i & 07))) {
719 static int LLdoskip(int e)
721 static int LLdoskip(e)
726 int list[LL_NTERMINALS+1];
727 #endif /* LL_USERHOOK */
735 LLx = LLuserhook(e, list);
737 #endif /* LL_USERHOOK */
739 if (LLtcnt[LLcsymb] != 0) {
741 if (!e || !LLx || LLcsymb == LLindex[e])
746 LLb = 1 << (LLcsymb & 07);
747 for (i = LL_NSETS - 1; i >= 0; i--) {
748 if (LLscnt[i] != 0) {
749 if (LLsets[LL_SSIZE*i+LLi] & LLb) {
751 if (!e || !LLx || LLcsymb == LLindex[e])
759 LLx = LLuserhook(e, list);
762 #endif /* LL_USERHOOK */
764 if ((!nc_done) && (LLsymb > 0)) {
783 void LLnewlevel(unsigned int *LLsinfo) {
785 LLnewlevel(LLsinfo) unsigned int *LLsinfo; {
790 LLsinfo[LL_NSETS+LL_NTERMINALS] = (unsigned) LLsymb;
791 LLsinfo[LL_NSETS+LL_NTERMINALS+1] = (unsigned) LLcsymb;
792 for (i = LL_NTERMINALS - 1; i >= 0; i--) {
793 LLsinfo[i] = LLtcnt[i];
796 for (i = LL_NSETS - 1; i >= 0; i--) {
797 LLsinfo[LL_NTERMINALS+i] = LLscnt[i];
805 void LLoldlevel(unsigned int *LLsinfo) {
807 LLoldlevel(LLsinfo) unsigned int *LLsinfo; {
813 for (i = 0; i < LL_NTERMINALS; i++) LL_assert(LLtcnt[i] == 0);
814 for (i = 0; i < LL_NSETS; i++) LL_assert(LLscnt[i] == 0);
817 for (i = LL_NSETS - 1; i >= 0; i--) {
818 LLscnt[i] = LLsinfo[LL_NTERMINALS+i];
820 for (i = LL_NTERMINALS - 1; i >= 0; i--) {
821 LLtcnt[i] = LLsinfo[i];
823 LLsymb = (int) LLsinfo[LL_NSETS+LL_NTERMINALS];
824 LLcsymb = (int) LLsinfo[LL_NSETS+LL_NTERMINALS+1];