xref: /original-bsd/old/pcc/mip/manifest (revision 2301fdfb)
1/*	manifest	4.3	85/01/18	*/
2
3# include <stdio.h>
4
5/*	manifest constant file for the lex/yacc interface */
6
7# define ERROR 1
8# define NAME 2
9# define STRING 3
10# define ICON 4
11# define FCON 5
12# define DCON 6
13# define PLUS 9
14# define MINUS 11
15# define MUL 14
16# define AND 17
17# define OR 20
18# define ER 22
19# define QUEST 24
20# define COLON 25
21# define ANDAND 26
22# define OROR 27
23
24/* the defines for ASOP, RELOP, EQUOP, DIVOP,
25   SHIFTOP, ICOP, UNOP, and STROP have been
26   moved to mfile1				*/
27/*	reserved words, etc */
28# define TYPE 36
29# define CLASS 37
30# define STRUCT 38
31# define RETURN 39
32# define GOTO 40
33# define IF 41
34# define ELSE 42
35# define SWITCH 43
36# define BREAK 44
37# define CONTINUE 45
38# define WHILE 46
39# define DO 47
40# define FOR 48
41# define DEFAULT 49
42# define CASE 50
43# define SIZEOF 51
44# define ENUM 52
45
46/*	little symbols, etc. */
47/*	namely,
48
49	LP	(
50	RP	)
51
52	LC	{
53	RC	}
54
55	LB	[
56	RB	]
57
58	CM	,
59	SM	;
60
61	*/
62
63/*  These defines are being moved to mfile1
64    to alleviate preprocessor problems with
65    second pass files: LP, RP, LC, RC */
66# define LB 57
67# define RB 58
68# define CM 59
69# define SM 60
70# define ASSIGN 61
71
72/*	END OF YACC */
73
74/*	left over tree building operators */
75#define COMOP	62		/* , operator */
76#define DIV	63		/* / */
77#define MOD	65		/* % */
78#define LS	67		/* << */
79#define RS	69		/* >> */
80#define DOT	71		/* . */
81#define STREF	72		/* -> */
82#define CALL	73		/* C function call */
83#define FORTCALL 76		/* Fortran function call */
84#define NOT	79		/* ! */
85#define COMPL	80		/* ~ */
86#define INCR	81		/* ++ */
87#define DECR	82		/* -- */
88#define EQ	83		/* == */
89#define NE	84		/* != */
90#define LE	85		/* <= */
91#define LT	86		/* < */
92#define GE	87		/* >= */
93#define GT	88		/* > */
94#define ULE	89		/* unsigned <= */
95#define ULT	90		/* unsigned < */
96#define UGE	91		/* unsigned >= */
97#define UGT	92		/* unsigned > */
98#define	SETBIT	93		/* unused */
99#define TESTBIT	94		/* unused */
100#define RESETBIT 95		/* unused */
101#define ARS	96		/* arithmetic >> */
102#define REG	97		/* register */
103#define OREG	98		/* offset from register */
104#define CCODES	99		/* condition codes */
105#define FREE	100		/* free node */
106#define STASG	101		/* structure assignment */
107#define STARG	102		/* structure parameter */
108#define STCALL	103		/* call to function returning structure */
109
110/* some conversion operators */
111#define FLD	106		/* field */
112#define SCONV	107		/* storage conversion */
113#define PCONV	108		/* pointer conversion */
114#define PMCONV	109		/* pointer multiply conversion (from +) */
115#define PVCONV	110		/* pointer divide conversion (from -) */
116
117/* special node operators, used for special contexts */
118#define FORCE	111		/* force result, for return values */
119#define CBRANCH	112		/* condition branch */
120#define INIT	113		/* data initialization */
121#define CAST	114		/* type cast */
122
123/*	node types */
124# define LTYPE 02
125# define UTYPE 04
126# define BITYPE 010
127
128	/* DSIZE is the size of the dope array */
129# define DSIZE CAST+1
130
131/*	type names, used in symbol table building */
132# define TNULL PTR    /* pointer to UNDEF */
133# define TVOID FTN	/* function returning UNDEF (for void) */
134# define UNDEF 0
135# define FARG 1
136# define CHAR 2
137# define SHORT 3
138# define INT 4
139# define LONG 5
140# define FLOAT 6
141# define DOUBLE 7
142# define STRTY 8
143# define UNIONTY 9
144# define ENUMTY 10
145# define MOETY 11
146# define UCHAR 12
147# define USHORT 13
148# define UNSIGNED 14
149# define ULONG 15
150
151# define ASG 1+
152# define UNARY 2+
153# define NOASG (-1)+
154# define NOUNARY (-2)+
155
156/*	various flags */
157# define NOLAB (-1)
158
159/* type modifiers */
160
161# define PTR  020
162# define FTN  040
163# define ARY  060
164
165/* type packing constants */
166
167# define TMASK 060
168# define TMASK1 0300
169# define TMASK2  0360
170# define BTMASK 017
171# define BTSHIFT 4
172# define TSHIFT 2
173
174/*	macros	*/
175
176# define MODTYPE(x,y) x = ( (x)&(~BTMASK))|(y)  /* set basic type of x to y */
177# define BTYPE(x)  ( (x)&BTMASK)   /* basic type of x */
178# define ISUNSIGNED(x) ((x)<=ULONG&&(x)>=UCHAR)
179# define UNSIGNABLE(x) ((x)<=LONG&&(x)>=CHAR)
180# define ENUNSIGN(x) ((x)+(UNSIGNED-INT))
181# define DEUNSIGN(x) ((x)+(INT-UNSIGNED))
182# define ISPTR(x) (( (x)&TMASK)==PTR)
183# define ISFTN(x)  (( (x)&TMASK)==FTN)  /* is x a function type */
184# define ISARY(x)   (( (x)&TMASK)==ARY)   /* is x an array type */
185# define INCREF(x) ((( (x)&~BTMASK)<<TSHIFT)|PTR|( (x)&BTMASK))
186# define DECREF(x) ((( (x)>>TSHIFT)&~BTMASK)|( (x)&BTMASK))
187# define SETOFF(x,y)   if( (x)%(y) != 0 ) (x) = ( ((x)/(y) + 1) * (y))
188		/* advance x to a multiple of y */
189# define NOFIT(x,y,z)   ( ( (x)%(z) + (y) ) > (z) )
190		/* can y bits be added to x without overflowing z */
191	/* pack and unpack field descriptors (size and offset) */
192# define PKFIELD(s,o) (( (o)<<6)| (s) )
193# define UPKFSZ(v)  ( (v) &077)
194# define UPKFOFF(v) ( (v) >>6)
195
196/*	operator information */
197
198# define TYFLG 016
199# define ASGFLG 01
200# define LOGFLG 020
201
202# define SIMPFLG 040
203# define COMMFLG 0100
204# define DIVFLG 0200
205# define FLOFLG 0400
206# define LTYFLG 01000
207# define CALLFLG 02000
208# define MULFLG 04000
209# define SHFFLG 010000
210# define ASGOPFLG 020000
211
212# define SPFLG 040000
213
214#define optype(o) (dope[o]&TYFLG)
215#define asgop(o) (dope[o]&ASGFLG)
216#define logop(o) (dope[o]&LOGFLG)
217#define callop(o) (dope[o]&CALLFLG)
218
219/*	table sizes	*/
220
221# define TREESZ 1000
222
223#ifndef FLEXNAMES
224# define NCHNAM 8  /* number of characters in a name */
225#else
226char *hash();
227char *savestr();
228char *tstr();
229extern int tstrused;
230extern char *tstrbuf[], **curtstr;
231#define	freetstr()	curtstr = tstrbuf, tstrused = 0
232#endif
233
234/*	common defined variables */
235
236extern int nerrors;  /* number of errors seen so far */
237
238typedef union ndu NODE;
239typedef unsigned int TWORD;
240# define NIL (NODE *)0
241extern int dope[];  /* a vector containing operator information */
242extern char *opst[];  /* a vector containing names for ops */
243
244# ifdef ONEPASS
245	/* in one-pass operation, define the tree nodes */
246
247union ndu {
248
249	struct {
250		int op;
251		int rall;
252		TWORD type;
253		int su;
254#ifndef FLEXNAMES
255		char name[NCHNAM];
256#else
257		char *name;
258		int stalign;
259#endif
260		NODE *left;
261		NODE *right;
262		}in; /* interior node */
263
264	struct {
265		int op;
266		int rall;
267		TWORD type;
268		int su;
269#ifndef FLEXNAMES
270		char name[NCHNAM];
271#else
272		char *name;
273		int stalign;
274#endif
275		CONSZ lval;
276		int rval;
277		}tn; /* terminal node */
278
279	struct {
280		int op, rall;
281		TWORD type;
282		int su;
283		int label;  /* for use with branching */
284		}bn; /* branch node */
285
286	struct {
287		int op, rall;
288		TWORD type;
289		int su;
290		int stsize;  /* sizes of structure objects */
291		int stalign;  /* alignment of structure objects */
292		}stn; /* structure node */
293
294	struct {
295		int op;
296		int cdim;
297		TWORD type;
298		int csiz;
299		}fn; /* front node */
300
301	struct {
302		/* this structure is used when a single precision constant
303		   is being computed */
304		int op;
305		int cdim;
306		TWORD type;
307		int csiz;
308		float fval;
309		}fpn; /* FCON node */
310
311	struct {
312		/* this structure is used when a double precision constant
313		   is being computed */
314		int op;
315		int cdim;
316		TWORD type;
317		int csiz;
318		double dval;
319		}dpn; /* DCON node */
320
321	};
322# endif
323# ifdef BUG2
324# define BUG1
325# endif
326# ifdef BUG3
327# define BUG2
328# define BUG1
329# endif
330# ifdef BUG4
331# define BUG1
332# define BUG2
333# define BUG3
334# endif
335# ifndef ONEPASS
336
337# ifndef EXPR
338# define EXPR '.'
339# endif
340# ifndef BBEG
341# define BBEG '['
342# endif
343# ifndef BEND
344# define BEND ']'
345# endif
346
347# endif
348