|
|
1.1 ! root 1: # include <stdio.h> ! 2: # include <ctype.h> ! 3: # include "files" ! 4: ! 5: /* MANIFEST CONSTANT DEFINITIONS */ ! 6: ! 7: /* base of nonterminal internal numbers */ ! 8: # define NTBASE 010000 ! 9: ! 10: /* internal codes for error and accept actions */ ! 11: ! 12: # define ERRCODE 8190 ! 13: # define ACCEPTCODE 8191 ! 14: ! 15: /* sizes and limits */ ! 16: ! 17: # ifdef HUGE ! 18: # define ACTSIZE 20000 ! 19: # define MEMSIZE 20000 ! 20: # define NSTATES 1000 ! 21: # define NTERMS 255 ! 22: # define NPROD 600 ! 23: # define NNONTERM 300 ! 24: # define TEMPSIZE 1200 ! 25: # define CNAMSZ 5000 ! 26: # define LSETSIZE 600 ! 27: # define WSETSIZE 350 ! 28: # endif ! 29: ! 30: # ifdef MEDIUM ! 31: # define ACTSIZE 4000 ! 32: # define MEMSIZE 5200 ! 33: # define NSTATES 600 ! 34: # define NTERMS 127 ! 35: # define NPROD 400 ! 36: # define NNONTERM 200 ! 37: # define TEMPSIZE 800 ! 38: # define CNAMSZ 4000 ! 39: # define LSETSIZE 450 ! 40: # define WSETSIZE 250 ! 41: # endif ! 42: ! 43: # define NAMESIZE 50 ! 44: # define NTYPES 63 ! 45: ! 46: # ifdef WORD32 ! 47: # define TBITSET ((32+NTERMS)/32) ! 48: ! 49: /* bit packing macros (may be machine dependent) */ ! 50: # define BIT(a,i) ((a)[(i)>>5] & (1<<((i)&037))) ! 51: # define SETBIT(a,i) ((a)[(i)>>5] |= (1<<((i)&037))) ! 52: ! 53: /* number of words needed to hold n+1 bits */ ! 54: # define NWORDS(n) (((n)+32)/32) ! 55: ! 56: # else ! 57: ! 58: # define TBITSET ((16+NTERMS)/16) ! 59: ! 60: /* bit packing macros (may be machine dependent) */ ! 61: # define BIT(a,i) ((a)[(i)>>4] & (1<<((i)&017))) ! 62: # define SETBIT(a,i) ((a)[(i)>>4] |= (1<<((i)&017))) ! 63: ! 64: /* number of words needed to hold n+1 bits */ ! 65: # define NWORDS(n) (((n)+16)/16) ! 66: # endif ! 67: ! 68: /* relationships which must hold: ! 69: TBITSET ints must hold NTERMS+1 bits... ! 70: WSETSIZE >= NNONTERM ! 71: LSETSIZE >= NNONTERM ! 72: TEMPSIZE >= NTERMS + NNONTERMs + 1 ! 73: TEMPSIZE >= NSTATES ! 74: */ ! 75: ! 76: /* associativities */ ! 77: ! 78: # define NOASC 0 /* no assoc. */ ! 79: # define LASC 1 /* left assoc. */ ! 80: # define RASC 2 /* right assoc. */ ! 81: # define BASC 3 /* binary assoc. */ ! 82: ! 83: /* flags for state generation */ ! 84: ! 85: # define DONE 0 ! 86: # define MUSTDO 1 ! 87: # define MUSTLOOKAHEAD 2 ! 88: ! 89: /* flags for a rule having an action, and being reduced */ ! 90: ! 91: # define ACTFLAG 04 ! 92: # define REDFLAG 010 ! 93: ! 94: /* output parser flags */ ! 95: # define YYFLAG1 (-1000) ! 96: ! 97: /* macros for getting associativity and precedence levels */ ! 98: ! 99: # define ASSOC(i) ((i)&03) ! 100: # define PLEVEL(i) (((i)>>4)&077) ! 101: # define TYPE(i) ((i>>10)&077) ! 102: ! 103: /* macros for setting associativity and precedence levels */ ! 104: ! 105: # define SETASC(i,j) i|=j ! 106: # define SETPLEV(i,j) i |= (j<<4) ! 107: # define SETTYPE(i,j) i |= (j<<10) ! 108: ! 109: /* looping macros */ ! 110: ! 111: # define TLOOP(i) for(i=1;i<=ntokens;++i) ! 112: # define NTLOOP(i) for(i=0;i<=nnonter;++i) ! 113: # define PLOOP(s,i) for(i=s;i<nprod;++i) ! 114: # define SLOOP(i) for(i=0;i<nstate;++i) ! 115: # define WSBUMP(x) ++x ! 116: # define WSLOOP(s,j) for(j=s;j<cwp;++j) ! 117: # define ITMLOOP(i,p,q) q=pstate[i+1];for(p=pstate[i];p<q;++p) ! 118: # define SETLOOP(i) for(i=0;i<tbitset;++i) ! 119: ! 120: /* I/O descriptors */ ! 121: ! 122: extern FILE * finput; /* input file */ ! 123: extern FILE * faction; /* file for saving actions */ ! 124: extern FILE * fdefine; /* file for # defines */ ! 125: extern FILE * fdebug; /* y.debug for strings for debugging */ ! 126: extern FILE * ftable; /* y.tab.c file */ ! 127: extern FILE * ftemp; /* tempfile to pass 2 */ ! 128: extern FILE * foutput; /* y.output file */ ! 129: ! 130: /* structure declarations */ ! 131: ! 132: struct looksets { ! 133: int lset[TBITSET]; ! 134: }; ! 135: ! 136: struct item { ! 137: int *pitem; ! 138: struct looksets *look; ! 139: }; ! 140: ! 141: struct toksymb { ! 142: char *name; ! 143: int value; ! 144: }; ! 145: ! 146: struct ntsymb { ! 147: char *name; ! 148: int tvalue; ! 149: }; ! 150: ! 151: struct wset { ! 152: int *pitem; ! 153: int flag; ! 154: struct looksets ws; ! 155: }; ! 156: ! 157: /* token information */ ! 158: ! 159: extern int ntokens ; /* number of tokens */ ! 160: extern struct toksymb tokset[]; ! 161: extern int toklev[]; /* vector with the precedence of the terminals */ ! 162: ! 163: /* nonterminal information */ ! 164: ! 165: extern int nnonter ; /* the number of nonterminals */ ! 166: extern struct ntsymb nontrst[]; ! 167: ! 168: /* grammar rule information */ ! 169: ! 170: extern int nprod ; /* number of productions */ ! 171: extern int *prdptr[]; /* pointers to descriptions of productions */ ! 172: extern int levprd[] ; /* contains production levels to break conflicts */ ! 173: extern int rlines[] ; /* src line number of productions */ ! 174: ! 175: /* state information */ ! 176: ! 177: extern int nstate ; /* number of states */ ! 178: extern struct item *pstate[]; /* pointers to the descriptions of the states */ ! 179: extern int tystate[]; /* contains type information about the states */ ! 180: extern int defact[]; /* the default action of the state */ ! 181: extern int tstates[]; /* the states deriving each token */ ! 182: extern int ntstates[]; /* the states deriving each nonterminal */ ! 183: extern int mstates[]; /* the continuation of the chains begun in tstates and ntstates */ ! 184: ! 185: /* lookahead set information */ ! 186: ! 187: extern struct looksets lkst[]; ! 188: extern int nolook; /* flag to turn off lookahead computations */ ! 189: ! 190: /* working set information */ ! 191: ! 192: extern struct wset wsets[]; ! 193: extern struct wset *cwp; ! 194: ! 195: /* storage for productions */ ! 196: ! 197: extern int mem0[]; ! 198: extern int *mem; ! 199: ! 200: /* storage for action table */ ! 201: ! 202: extern int amem[]; /* action table storage */ ! 203: extern int *memp ; /* next free action table position */ ! 204: extern int indgo[]; /* index to the stored goto table */ ! 205: ! 206: /* temporary vector, indexable by states, terms, or ntokens */ ! 207: ! 208: extern int temp1[]; ! 209: extern int lineno; /* current line number */ ! 210: ! 211: /* statistics collection variables */ ! 212: ! 213: extern int zzgoent ; ! 214: extern int zzgobest ; ! 215: extern int zzacent ; ! 216: extern int zzexcp ; ! 217: extern int zzclose ; ! 218: extern int zzrrconf ; ! 219: extern int zzsrconf ; ! 220: /* define functions with strange types... */ ! 221: ! 222: extern char *cstash(); ! 223: extern struct looksets *flset(); ! 224: extern char *symnam(); ! 225: extern char *writem(); ! 226: ! 227: /* default settings for a number of macros */ ! 228: ! 229: /* name of yacc tempfiles */ ! 230: ! 231: # ifndef TEMPNAME ! 232: # define TEMPNAME "y.tmp.XXXXXX" ! 233: # endif ! 234: extern char *tempname; ! 235: ! 236: # ifndef ACTNAME ! 237: # define ACTNAME "y.acts.XXXXXX" ! 238: # endif ! 239: extern char *actname; ! 240: ! 241: /* output file name */ ! 242: ! 243: # ifndef OFILE ! 244: # define OFILE "tab.c" ! 245: # endif ! 246: ! 247: /* user output file name */ ! 248: ! 249: # ifndef FILEU ! 250: # define FILEU "output" ! 251: # endif ! 252: ! 253: /* output file for # defines */ ! 254: ! 255: # ifndef FILED ! 256: # define FILED "tab.h" ! 257: # endif ! 258: #define FILEDEBUG "debug" ! 259: ! 260: /* command to clobber tempfiles after use */ ! 261: ! 262: # ifndef ZAPFILE ! 263: # define ZAPFILE(x) unlink(x) ! 264: # endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.