xref: /csrg-svn/usr.bin/pascal/eyacc/ey.h (revision 19568)
1*19568Smckusick /*
2*19568Smckusick  * Copyright (c) 1979 Regents of the University of California.
3*19568Smckusick  * All rights reserved.  The Berkeley software License Agreement
4*19568Smckusick  * specifies the terms and conditions for redistribution.
5*19568Smckusick  *
6*19568Smckusick  *	@(#)ey.h	5.1 (Berkeley) 04/29/85
7*19568Smckusick  */
8*19568Smckusick 
9*19568Smckusick #include <stdio.h>
10*19568Smckusick /*  MANIFEST CONSTANT DEFINITIONS */
11*19568Smckusick 
12*19568Smckusick # define NTBASE 010000
13*19568Smckusick 
14*19568Smckusick   /* internal codes for error and accept actions */
15*19568Smckusick 
16*19568Smckusick # define ERRCODE  8190
17*19568Smckusick # define ACCEPTCODE 8191
18*19568Smckusick 
19*19568Smckusick # define errfileno stderr      /* file number for erros and reduction message */
20*19568Smckusick # define _tbitset 6  /* 16*_tbitset - 1 >= _nterms */
21*19568Smckusick 
22*19568Smckusick extern int tbitset;  /* number of wds of lookahead vector */
23*19568Smckusick extern int nolook;  /* flag to turn off lookahed computations */
24*19568Smckusick struct looksets { int lset[ _tbitset ]; } ;
25*19568Smckusick struct item { int *pitem; struct looksets *look; } ;
26*19568Smckusick 
27*19568Smckusick   /* output actions */
28*19568Smckusick 
29*19568Smckusick # define ERRACT 4096
30*19568Smckusick # define SHIFTACT 8192
31*19568Smckusick # define REDUCACT 12288
32*19568Smckusick # define ACCEPTACT 16384
33*19568Smckusick 
34*19568Smckusick # define _REGISTER register
35*19568Smckusick 
36*19568Smckusick extern int nstate ;		/* number of states */
37*19568Smckusick extern struct item *pstate[];	/* pointers to the descriptions of the states */
38*19568Smckusick extern int apstate[];		/* index to actions in amem by state */
39*19568Smckusick extern int actsiz;  	/* size of the action table array */
40*19568Smckusick extern int tystate[];	/* contains type information about the states */
41*19568Smckusick   /* 0 = simple state, completely generated
42*19568Smckusick      1 = state awaiting generation
43*19568Smckusick      2 = state with an empty production in closure
44*19568Smckusick      */
45*19568Smckusick extern int stsize ;	/* maximum number of states, at present */
46*19568Smckusick extern int memsiz ;	/* maximum size for productions and states */
47*19568Smckusick extern int mem0[] ; /* added production */
48*19568Smckusick extern int *mem ;
49*19568Smckusick extern int amem[];  /* action table storage */
50*19568Smckusick extern int actsiz;  /* action table size */
51*19568Smckusick extern int memact ;		/* next free action table position */
52*19568Smckusick extern int nprod ;	/* number of productions */
53*19568Smckusick extern int *prdptr[];	/* pointers to descriptions of productions */
54*19568Smckusick extern int prdlim; /* the number of productions allowed */
55*19568Smckusick extern int levprd[] ;	/* contains production levels to break conflicts */
56*19568Smckusick   /* last two bits code associativity:
57*19568Smckusick        0 = no definition
58*19568Smckusick        1 = left associative
59*19568Smckusick        2 = binary
60*19568Smckusick        3 = right associative
61*19568Smckusick      bit 04 is 1 if the production has an action
62*19568Smckusick      the high 13 bits have the production level
63*19568Smckusick      */
64*19568Smckusick extern int nterms ;	/* number of terminals */
65*19568Smckusick extern int nerrors;	/* number of errors */
66*19568Smckusick extern int fatfl;  	/* if on, error is fatal */
67*19568Smckusick   /*	the ascii representations of the terminals	*/
68*19568Smckusick extern int extval;  /* start of output values */
69*19568Smckusick extern struct sxxx1 {char *name; int value;} trmset[];
70*19568Smckusick extern char cnames[];
71*19568Smckusick extern int cnamsz;
72*19568Smckusick extern char *cnamp;
73*19568Smckusick extern int maxtmp ;	/* the size of the temp arrays */
74*19568Smckusick  /* temporary vectors, indexable by states, terms, or nterms */
75*19568Smckusick extern int temp1[];
76*19568Smckusick extern int temp2[];
77*19568Smckusick extern int trmlev[];	/* vector with the precedence of the terminals */
78*19568Smckusick   /* The levels are the same as for levprd, but bit 04 is always 0 */
79*19568Smckusick   /* the ascii representations of the nonterminals */
80*19568Smckusick extern struct sxxx2 { char *name; } nontrst[];
81*19568Smckusick extern int indgo[];		/* index to the stored goto table */
82*19568Smckusick extern int ***pres; /* vector of pointers to the productions yielding each nonterminal */
83*19568Smckusick extern struct looksets **pfirst; /* vector of pointers to first sets for each nonterminal */
84*19568Smckusick extern char *pempty; /* table of nonterminals nontrivially deriving e */
85*19568Smckusick extern char stateflags[]; /* flags defining properties of a state (see below) */
86*19568Smckusick #define GENLAMBDA   1	/* the state can nontrivially derive lambda */
87*19568Smckusick #define SINGLE_NT   2	/* the state has a single nonterminal before its dot */
88*19568Smckusick #define NEEDSREDUCE 4	/* the state needs a full reduce state generated */
89*19568Smckusick extern struct looksets lastate[]; /* saved lookahead sets */
90*19568Smckusick extern unsigned char lookstate[]; /* index mapping states to saved lookaheads */
91*19568Smckusick extern int savedlook; /* number of saved lookahead sets used */
92*19568Smckusick extern int maxlastate; /* maximum number of saved lookahead sets */
93*19568Smckusick extern int nnonter ;	/* the number of nonterminals */
94*19568Smckusick extern int lastred ;	/* the number of the last reduction of a state */
95*19568Smckusick extern FILE *ftable;		/* y.tab.c file */
96*19568Smckusick extern FILE *foutput;		/* y.output file */
97*19568Smckusick extern FILE *cin;		/* current input file */
98*19568Smckusick extern FILE *cout;		/* current output file */
99*19568Smckusick extern int arrndx;
100*19568Smckusick extern int zzcwset;
101*19568Smckusick extern int zzpairs ;
102*19568Smckusick extern int zzgoent ;
103*19568Smckusick extern int zzgobest ;
104*19568Smckusick extern int zzacent ;
105*19568Smckusick extern int zzacsave ;
106*19568Smckusick extern int zznsave ;
107*19568Smckusick extern int zzclose ;
108*19568Smckusick extern int zzrrconf ;
109*19568Smckusick extern int zzsrconf ;
110*19568Smckusick extern char *ctokn;
111*19568Smckusick struct {int **ppi;} ;
112*19568Smckusick extern int ntlim ;	/* maximum number of nonterminals */
113*19568Smckusick extern int tlim ;	/* maximum number of terminals */
114*19568Smckusick extern int lineno; /* current line number */
115*19568Smckusick extern int peekc; /* look-ahead character */
116*19568Smckusick extern int tstates[];
117*19568Smckusick extern int ntstates[];
118*19568Smckusick extern int mstates[];
119*19568Smckusick 
120*19568Smckusick extern struct looksets clset;
121*19568Smckusick extern struct looksets lkst[];
122*19568Smckusick extern int nlset;  /* next lookahead set index */
123*19568Smckusick extern int lsetsz; /* number of lookahead sets */
124*19568Smckusick 
125*19568Smckusick extern struct wset { int *pitem, flag, ws[ _tbitset ]; } wsets[];
126*19568Smckusick extern int cwset;
127*19568Smckusick extern int wssize;
128*19568Smckusick extern int lambdarule; /* index to rule that derives lambda */
129*19568Smckusick 
130*19568Smckusick extern int numbval;  /* the value of an input number */
131*19568Smckusick extern int rflag;  /* ratfor flag */
132*19568Smckusick extern int oflag;  /* optimization flag */
133*19568Smckusick extern int ndefout;  /* number of defined symbols output */
134*19568Smckusick 
135*19568Smckusick extern int machine;
136*19568Smckusick 
137*19568Smckusick # define UNIX 1
138*19568Smckusick # define GCOS 2
139*19568Smckusick # define IBM 3
140*19568Smckusick 
141*19568Smckusick struct looksets *flset();
142