147969Sbostic /*- 2*62087Sbostic * Copyright (c) 1979, 1993 3*62087Sbostic * The Regents of the University of California. All rights reserved. 419568Smckusick * 547969Sbostic * %sccs.include.proprietary.c% 647969Sbostic * 7*62087Sbostic * @(#)ey.h 8.1 (Berkeley) 06/06/93 819568Smckusick */ 919568Smckusick 1019568Smckusick #include <stdio.h> 1119568Smckusick /* MANIFEST CONSTANT DEFINITIONS */ 1219568Smckusick 1319568Smckusick # define NTBASE 010000 1419568Smckusick 1519568Smckusick /* internal codes for error and accept actions */ 1619568Smckusick 1719568Smckusick # define ERRCODE 8190 1819568Smckusick # define ACCEPTCODE 8191 1919568Smckusick 2019568Smckusick # define errfileno stderr /* file number for erros and reduction message */ 2119568Smckusick # define _tbitset 6 /* 16*_tbitset - 1 >= _nterms */ 2219568Smckusick 2319568Smckusick extern int tbitset; /* number of wds of lookahead vector */ 2419568Smckusick extern int nolook; /* flag to turn off lookahed computations */ 2519568Smckusick struct looksets { int lset[ _tbitset ]; } ; 2619568Smckusick struct item { int *pitem; struct looksets *look; } ; 2719568Smckusick 2819568Smckusick /* output actions */ 2919568Smckusick 3019568Smckusick # define ERRACT 4096 3119568Smckusick # define SHIFTACT 8192 3219568Smckusick # define REDUCACT 12288 3319568Smckusick # define ACCEPTACT 16384 3419568Smckusick 3519568Smckusick # define _REGISTER register 3619568Smckusick 3719568Smckusick extern int nstate ; /* number of states */ 3819568Smckusick extern struct item *pstate[]; /* pointers to the descriptions of the states */ 3919568Smckusick extern int apstate[]; /* index to actions in amem by state */ 4019568Smckusick extern int actsiz; /* size of the action table array */ 4119568Smckusick extern int tystate[]; /* contains type information about the states */ 4219568Smckusick /* 0 = simple state, completely generated 4319568Smckusick 1 = state awaiting generation 4419568Smckusick 2 = state with an empty production in closure 4519568Smckusick */ 4619568Smckusick extern int stsize ; /* maximum number of states, at present */ 4719568Smckusick extern int memsiz ; /* maximum size for productions and states */ 4819568Smckusick extern int mem0[] ; /* added production */ 4919568Smckusick extern int *mem ; 5019568Smckusick extern int amem[]; /* action table storage */ 5119568Smckusick extern int actsiz; /* action table size */ 5219568Smckusick extern int memact ; /* next free action table position */ 5319568Smckusick extern int nprod ; /* number of productions */ 5419568Smckusick extern int *prdptr[]; /* pointers to descriptions of productions */ 5519568Smckusick extern int prdlim; /* the number of productions allowed */ 5619568Smckusick extern int levprd[] ; /* contains production levels to break conflicts */ 5719568Smckusick /* last two bits code associativity: 5819568Smckusick 0 = no definition 5919568Smckusick 1 = left associative 6019568Smckusick 2 = binary 6119568Smckusick 3 = right associative 6219568Smckusick bit 04 is 1 if the production has an action 6319568Smckusick the high 13 bits have the production level 6419568Smckusick */ 6519568Smckusick extern int nterms ; /* number of terminals */ 6619568Smckusick extern int nerrors; /* number of errors */ 6719568Smckusick extern int fatfl; /* if on, error is fatal */ 6819568Smckusick /* the ascii representations of the terminals */ 6919568Smckusick extern int extval; /* start of output values */ 7019568Smckusick extern struct sxxx1 {char *name; int value;} trmset[]; 7119568Smckusick extern char cnames[]; 7219568Smckusick extern int cnamsz; 7319568Smckusick extern char *cnamp; 7419568Smckusick extern int maxtmp ; /* the size of the temp arrays */ 7519568Smckusick /* temporary vectors, indexable by states, terms, or nterms */ 7619568Smckusick extern int temp1[]; 7719568Smckusick extern int temp2[]; 7819568Smckusick extern int trmlev[]; /* vector with the precedence of the terminals */ 7919568Smckusick /* The levels are the same as for levprd, but bit 04 is always 0 */ 8019568Smckusick /* the ascii representations of the nonterminals */ 8119568Smckusick extern struct sxxx2 { char *name; } nontrst[]; 8219568Smckusick extern int indgo[]; /* index to the stored goto table */ 8319568Smckusick extern int ***pres; /* vector of pointers to the productions yielding each nonterminal */ 8419568Smckusick extern struct looksets **pfirst; /* vector of pointers to first sets for each nonterminal */ 8519568Smckusick extern char *pempty; /* table of nonterminals nontrivially deriving e */ 8619568Smckusick extern char stateflags[]; /* flags defining properties of a state (see below) */ 8719568Smckusick #define GENLAMBDA 1 /* the state can nontrivially derive lambda */ 8819568Smckusick #define SINGLE_NT 2 /* the state has a single nonterminal before its dot */ 8919568Smckusick #define NEEDSREDUCE 4 /* the state needs a full reduce state generated */ 9019568Smckusick extern struct looksets lastate[]; /* saved lookahead sets */ 9119568Smckusick extern unsigned char lookstate[]; /* index mapping states to saved lookaheads */ 9219568Smckusick extern int savedlook; /* number of saved lookahead sets used */ 9319568Smckusick extern int maxlastate; /* maximum number of saved lookahead sets */ 9419568Smckusick extern int nnonter ; /* the number of nonterminals */ 9519568Smckusick extern int lastred ; /* the number of the last reduction of a state */ 9619568Smckusick extern FILE *ftable; /* y.tab.c file */ 9719568Smckusick extern FILE *foutput; /* y.output file */ 9819568Smckusick extern FILE *cin; /* current input file */ 9919568Smckusick extern FILE *cout; /* current output file */ 10019568Smckusick extern int arrndx; 10119568Smckusick extern int zzcwset; 10219568Smckusick extern int zzpairs ; 10319568Smckusick extern int zzgoent ; 10419568Smckusick extern int zzgobest ; 10519568Smckusick extern int zzacent ; 10619568Smckusick extern int zzacsave ; 10719568Smckusick extern int zznsave ; 10819568Smckusick extern int zzclose ; 10919568Smckusick extern int zzrrconf ; 11019568Smckusick extern int zzsrconf ; 11119568Smckusick extern char *ctokn; 11219568Smckusick struct {int **ppi;} ; 11319568Smckusick extern int ntlim ; /* maximum number of nonterminals */ 11419568Smckusick extern int tlim ; /* maximum number of terminals */ 11519568Smckusick extern int lineno; /* current line number */ 11619568Smckusick extern int peekc; /* look-ahead character */ 11719568Smckusick extern int tstates[]; 11819568Smckusick extern int ntstates[]; 11919568Smckusick extern int mstates[]; 12019568Smckusick 12119568Smckusick extern struct looksets clset; 12219568Smckusick extern struct looksets lkst[]; 12319568Smckusick extern int nlset; /* next lookahead set index */ 12419568Smckusick extern int lsetsz; /* number of lookahead sets */ 12519568Smckusick 12619568Smckusick extern struct wset { int *pitem, flag, ws[ _tbitset ]; } wsets[]; 12719568Smckusick extern int cwset; 12819568Smckusick extern int wssize; 12919568Smckusick extern int lambdarule; /* index to rule that derives lambda */ 13019568Smckusick 13119568Smckusick extern int numbval; /* the value of an input number */ 13219568Smckusick extern int rflag; /* ratfor flag */ 13319568Smckusick extern int oflag; /* optimization flag */ 13419568Smckusick extern int ndefout; /* number of defined symbols output */ 13519568Smckusick 13619568Smckusick struct looksets *flset(); 137