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