147968Sbostic /*- 2*62087Sbostic * Copyright (c) 1979, 1993 3*62087Sbostic * The Regents of the University of California. All rights reserved. 447968Sbostic * 547968Sbostic * %sccs.include.proprietary.c% 619569Smckusick */ 719569Smckusick 819569Smckusick #ifndef lint 9*62087Sbostic static char sccsid[] = "@(#)ey0.c 8.1 (Berkeley) 06/06/93"; 1047968Sbostic #endif /* not lint */ 1119569Smckusick 1219569Smckusick #include <stdio.h> 1319569Smckusick # define _actsize 2500 1419569Smckusick # define _memsize 3000 1519569Smckusick # define _nstates 700 1619569Smckusick # define _nterms 95 1719569Smckusick # define _nprod 300 1819569Smckusick # define _nnonterm 150 1919569Smckusick # define _tempsize 700 2019569Smckusick # define _cnamsz 3500 2119569Smckusick # define _lsetsize 600 2219569Smckusick # define _wsetsize 400 2319569Smckusick # define _maxlastate 100 2419569Smckusick 2519569Smckusick # define _tbitset 6 2619569Smckusick 2719569Smckusick int tbitset; /* size of lookahed sets */ 2819569Smckusick int nolook = 0; /* flag to suppress lookahead computations */ 2919569Smckusick struct looksets { int lset[ _tbitset ]; } ; 3019569Smckusick struct item { int *pitem; } ; 3119569Smckusick 3219569Smckusick /* this file contains the definitions for most externally known data */ 3319569Smckusick 3419569Smckusick int nstate = 0; /* number of states */ 3519569Smckusick struct item *pstate[_nstates]; /* pointers to the descriptions of the states */ 3619569Smckusick int apstate[_nstates]; /* index to the actions for the states */ 3719569Smckusick int tystate[_nstates]; /* contains type information about the states */ 3819569Smckusick int stsize = _nstates; /* maximum number of states, at present */ 3919569Smckusick int memsiz = _memsize; /* maximum size for productions and states */ 4019569Smckusick int mem0[_memsize] ; /* production storage */ 4119569Smckusick int *mem = mem0; 4219569Smckusick int amem[_actsize]; /* action table storage */ 4319569Smckusick int actsiz = _actsize; /* action table size */ 4419569Smckusick int memact = 0; /* next free action table position */ 4519569Smckusick int nprod = 1; /* number of productions */ 4619569Smckusick int *prdptr[_nprod]; /* pointers to descriptions of productions */ 4719569Smckusick int prdlim = _nprod ; /* the maximum number of productions */ 4819569Smckusick /* levprd - productions levels to break conflicts */ 4919569Smckusick int levprd[_nprod] = {0,0}; 5019569Smckusick /* last two bits code associativity: 5119569Smckusick 0 = no definition 5219569Smckusick 1 = left associative 5319569Smckusick 2 = binary 5419569Smckusick 3 = right associative 5519569Smckusick bit 04 is 1 if the production has an action 5619569Smckusick the high 13 bits have the production level 5719569Smckusick */ 5819569Smckusick int nterms = 0; /* number of terminals */ 5919569Smckusick int tlim = _nterms ; /* the maximum number of terminals */ 6019569Smckusick /* the ascii representations of the terminals */ 6119569Smckusick int extval = 0; /* start of output values */ 6219569Smckusick struct sxxx1 {char *name; int value;} trmset[_nterms]; 6319569Smckusick char cnames[_cnamsz]; 6419569Smckusick int cnamsz = _cnamsz; 6519569Smckusick char *cnamp; 6619569Smckusick int maxtmp = _tempsize; /* the size of the temp1 array */ 6719569Smckusick int temp1[_tempsize]; /* temporary storage, indexed by terms + nterms or states */ 6819569Smckusick int temp2[_nnonterm]; /* temporary storage indexed by nonterminals */ 6919569Smckusick int trmlev[_nterms]; /* vector with the precedence of the terminals */ 7019569Smckusick /* The levels are the same as for levprd, but bit 04 is always 0 */ 7119569Smckusick /* the ascii representations of the nonterminals */ 7219569Smckusick struct sxxx2 { char *name; } nontrst[_nnonterm]; 7319569Smckusick int ntlim = _nnonterm ; /* limit to the number of nonterminals */ 7419569Smckusick int indgo[_nstates]; /* index to the stored goto table */ 7519569Smckusick int ***pres; /* vector of pointers to the productions yielding each nonterminal */ 7619569Smckusick struct looksets **pfirst; /* vector of pointers to first sets for each nonterminal */ 7719569Smckusick int *pempty = 0 ; /* table of nonterminals nontrivially deriving e */ 7819569Smckusick int nnonter = -1; /* the number of nonterminals */ 7919569Smckusick int lastred = 0; /* the number of the last reduction of a state */ 8019569Smckusick FILE *ftable; /* y.tab.c file */ 8119569Smckusick FILE *foutput; /* y.output file */ 8219569Smckusick FILE *cout = stdout; 8319569Smckusick int arrndx; /* used in the output of arrays on y.tab.c */ 8419569Smckusick int zzcwset = 0; 8519569Smckusick int zzpairs = 0; 8619569Smckusick int zzgoent = 0; 8719569Smckusick int zzgobest = 0; 8819569Smckusick int zzacent = 0; 8919569Smckusick int zzacsave = 0; 9019569Smckusick int zznsave = 0; 9119569Smckusick int zzclose = 0; 9219569Smckusick int zzsrconf = 0; 9319569Smckusick int zzrrconf = 0; 9419569Smckusick char *ctokn; 9519569Smckusick int lineno = 1; /* current input line number */ 9619569Smckusick int peekc = -1; /* look-ahead character */ 9719569Smckusick int tstates[ _nterms ]; /* states generated by terminal gotos */ 9819569Smckusick int ntstates[ _nnonterm ]; /* states generated by nonterminal gotos */ 9919569Smckusick int mstates[ _nstates ]; /* chain of overflows of term/nonterm generation lists */ 10019569Smckusick 10119569Smckusick struct looksets clset; 10219569Smckusick struct looksets lkst [ _lsetsize ]; 10319569Smckusick int nlset = 0; /* next lookahead set index */ 10419569Smckusick int lsetsz = _lsetsize; /* number of lookahead sets */ 10519569Smckusick 10619569Smckusick struct wset { int *pitem, flag, ws[_tbitset]; } wsets[ _wsetsize ]; 10719569Smckusick int cwset; 10819569Smckusick int wssize = _wsetsize; 10919569Smckusick int lambdarule = 0; 11019569Smckusick 11119569Smckusick char stateflags[ _nstates ]; 11219569Smckusick unsigned char lookstate[ _nstates ]; 11319569Smckusick struct looksets lastate[ _maxlastate ]; 11419569Smckusick int maxlastate = _maxlastate; 11519569Smckusick int savedlook = 1; 11619569Smckusick 11719569Smckusick int numbval; /* the value of an input number */ 11819569Smckusick int rflag = 0; /* ratfor flag */ 11919569Smckusick int oflag = 0; /* optimization flag */ 12019569Smckusick 12119569Smckusick int ndefout = 3; /* number of defined symbols output */ 12219569Smckusick int nerrors = 0; /* number of errors */ 12319569Smckusick int fatfl = 1; /* if on, error is fatal */ 12419569Smckusick 125