1 /*- 2 * Copyright (c) 1979, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.proprietary.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)ey0.c 8.1 (Berkeley) 06/06/93"; 10 #endif /* not lint */ 11 12 #include <stdio.h> 13 # define _actsize 2500 14 # define _memsize 3000 15 # define _nstates 700 16 # define _nterms 95 17 # define _nprod 300 18 # define _nnonterm 150 19 # define _tempsize 700 20 # define _cnamsz 3500 21 # define _lsetsize 600 22 # define _wsetsize 400 23 # define _maxlastate 100 24 25 # define _tbitset 6 26 27 int tbitset; /* size of lookahed sets */ 28 int nolook = 0; /* flag to suppress lookahead computations */ 29 struct looksets { int lset[ _tbitset ]; } ; 30 struct item { int *pitem; } ; 31 32 /* this file contains the definitions for most externally known data */ 33 34 int nstate = 0; /* number of states */ 35 struct item *pstate[_nstates]; /* pointers to the descriptions of the states */ 36 int apstate[_nstates]; /* index to the actions for the states */ 37 int tystate[_nstates]; /* contains type information about the states */ 38 int stsize = _nstates; /* maximum number of states, at present */ 39 int memsiz = _memsize; /* maximum size for productions and states */ 40 int mem0[_memsize] ; /* production storage */ 41 int *mem = mem0; 42 int amem[_actsize]; /* action table storage */ 43 int actsiz = _actsize; /* action table size */ 44 int memact = 0; /* next free action table position */ 45 int nprod = 1; /* number of productions */ 46 int *prdptr[_nprod]; /* pointers to descriptions of productions */ 47 int prdlim = _nprod ; /* the maximum number of productions */ 48 /* levprd - productions levels to break conflicts */ 49 int levprd[_nprod] = {0,0}; 50 /* last two bits code associativity: 51 0 = no definition 52 1 = left associative 53 2 = binary 54 3 = right associative 55 bit 04 is 1 if the production has an action 56 the high 13 bits have the production level 57 */ 58 int nterms = 0; /* number of terminals */ 59 int tlim = _nterms ; /* the maximum number of terminals */ 60 /* the ascii representations of the terminals */ 61 int extval = 0; /* start of output values */ 62 struct sxxx1 {char *name; int value;} trmset[_nterms]; 63 char cnames[_cnamsz]; 64 int cnamsz = _cnamsz; 65 char *cnamp; 66 int maxtmp = _tempsize; /* the size of the temp1 array */ 67 int temp1[_tempsize]; /* temporary storage, indexed by terms + nterms or states */ 68 int temp2[_nnonterm]; /* temporary storage indexed by nonterminals */ 69 int trmlev[_nterms]; /* vector with the precedence of the terminals */ 70 /* The levels are the same as for levprd, but bit 04 is always 0 */ 71 /* the ascii representations of the nonterminals */ 72 struct sxxx2 { char *name; } nontrst[_nnonterm]; 73 int ntlim = _nnonterm ; /* limit to the number of nonterminals */ 74 int indgo[_nstates]; /* index to the stored goto table */ 75 int ***pres; /* vector of pointers to the productions yielding each nonterminal */ 76 struct looksets **pfirst; /* vector of pointers to first sets for each nonterminal */ 77 int *pempty = 0 ; /* table of nonterminals nontrivially deriving e */ 78 int nnonter = -1; /* the number of nonterminals */ 79 int lastred = 0; /* the number of the last reduction of a state */ 80 FILE *ftable; /* y.tab.c file */ 81 FILE *foutput; /* y.output file */ 82 FILE *cout = stdout; 83 int arrndx; /* used in the output of arrays on y.tab.c */ 84 int zzcwset = 0; 85 int zzpairs = 0; 86 int zzgoent = 0; 87 int zzgobest = 0; 88 int zzacent = 0; 89 int zzacsave = 0; 90 int zznsave = 0; 91 int zzclose = 0; 92 int zzsrconf = 0; 93 int zzrrconf = 0; 94 char *ctokn; 95 int lineno = 1; /* current input line number */ 96 int peekc = -1; /* look-ahead character */ 97 int tstates[ _nterms ]; /* states generated by terminal gotos */ 98 int ntstates[ _nnonterm ]; /* states generated by nonterminal gotos */ 99 int mstates[ _nstates ]; /* chain of overflows of term/nonterm generation lists */ 100 101 struct looksets clset; 102 struct looksets lkst [ _lsetsize ]; 103 int nlset = 0; /* next lookahead set index */ 104 int lsetsz = _lsetsize; /* number of lookahead sets */ 105 106 struct wset { int *pitem, flag, ws[_tbitset]; } wsets[ _wsetsize ]; 107 int cwset; 108 int wssize = _wsetsize; 109 int lambdarule = 0; 110 111 char stateflags[ _nstates ]; 112 unsigned char lookstate[ _nstates ]; 113 struct looksets lastate[ _maxlastate ]; 114 int maxlastate = _maxlastate; 115 int savedlook = 1; 116 117 int numbval; /* the value of an input number */ 118 int rflag = 0; /* ratfor flag */ 119 int oflag = 0; /* optimization flag */ 120 121 int ndefout = 3; /* number of defined symbols output */ 122 int nerrors = 0; /* number of errors */ 123 int fatfl = 1; /* if on, error is fatal */ 124 125