xref: /original-bsd/usr.bin/pascal/src/tree_ty.h (revision 4e9331e4)
1 /*
2  * Copyright (c) 1980 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  *	@(#)tree_ty.h	5.1 (Berkeley) 06/05/85
7  */
8 
9 typedef struct /* T_FORU, T_FORD */
10 {
11     int		line_no; 	/* line number of for */
12     struct	tnode	*init_asg;	/* initialization */
13     struct	tnode	*term_expr;	/* termination expresssion */
14     struct	tnode	*for_stmnt;	/* for statement */
15 } FOR_NODE;
16 typedef struct  /* T_ASGN */
17 {
18     int		line_no;	/* line number of := */
19     struct	tnode	*lhs_var;
20     struct	tnode	*rhs_expr;
21 } ASG_NODE;
22 #ifndef PTREE
23 typedef struct				/* T_VAR */
24 {
25     int 		line_no;
26     char		*cptr;
27     struct tnode	*qual;		/* list node */
28 } VAR_NODE;
29 typedef struct		/* T_FIELD */
30 {
31     char		*id_ptr;
32     struct tnode	*other;
33 } FIELD_NODE;
34 #else
35 typedef struct				/* T_VAR */
36 {
37     int 		line_no;
38     char		*cptr;
39     struct tnode	*qual;
40     struct nl		*nl_entry;
41 } VAR_NODE;
42 typedef struct		/* T_FIELD */
43 {
44     char		*id_ptr;
45     struct tnode	*other;
46     struct nl		*nl_entry;
47 } FIELD_NODE;
48 #endif
49 typedef struct				/* T_MOD, T_MULT, T_DIVD, T_DIV,
50 					   T_AND, T_ADD, T_SUB, T_OR,
51 					   T_EQ, T_LT, T_GT, T_NE, T_LE
52 					   T_GE, T_IN */
53 {
54     int		const_tag;
55     struct	tnode	*lhs;
56     struct	tnode	*rhs;
57 } EXPR_NODE;
58 typedef struct			/* T_LISTPP */
59 {
60     struct tnode *list;  /* check the types on these,
61 			    this is used in pclvalue and lvalue */
62     struct tnode *next;
63 } LIST_NODE;
64 typedef struct			/* T_IF, T_IFEL, T_IFX */
65 {
66     int           line_no;
67     struct tnode *cond_expr;
68     struct tnode *then_stmnt;
69     struct tnode *else_stmnt;
70 } IF_NODE;
71 typedef struct			/* T_MINUS, T_PLUS, T_NOT */
72 {
73     int		const_tag;
74     struct tnode 	*expr;
75 } UN_EXPR;
76 typedef struct /* T_PDEC, T_FDEC, T_PROG */
77 {
78     int	line_no;
79     char	*id_ptr;
80     struct tnode	*param_list;
81     struct tnode	*type;
82 } P_DEC;
83 typedef struct	/* T_PVAL, T_PVAR */
84 {
85     struct tnode	*id_list;
86     struct tnode	*type;
87 } PARAM;
88 typedef struct		/* T_PFUNC, T_PPROC */
89 {
90     struct tnode	*id_list,
91 			*type,
92 			*param_list;
93     int			line_no;
94 } PFUNC_NODE;
95 typedef struct		/* T_NIL */
96 {
97     int	const_tag;
98 } NIL_NODE;
99 typedef struct		/* T_STRNG, T_INT, T_FINT, T_BINT */
100 {
101     int		const_tag;
102     char	*cptr;
103 } CONST_NODE;
104 typedef struct		/* T_CSTRNG, T_ID, T_CFINT, T_CINT, T_CBINT */
105 {
106     char	*cptr;
107 } CHAR_CONST;
108 typedef struct		/* T_PLUSC, T_MINUSC */
109 {
110     struct tnode	*number;
111 } SIGN_CONST;
112 #ifdef PTREE
113 typedef struct
114 {
115     int	line_no
116     struct tnode	*type;
117     struct nl		*nl_entry;
118 } COMP_TY;
119 #else
120 typedef struct		/* T_TYPACK, T_TYSCAL, T_TYFILE, T_TYSET, T_TYREC */
121 {
122     int		  line_no;
123     struct tnode *type;
124 } COMP_TY;
125 #endif
126 typedef struct		/* T_TYPTR */
127 {
128     int			 line_no;
129     struct tnode	*id_node;
130 } PTR_TY;
131 typedef struct		/* T_TYRANG */
132 {
133     int			 line_no;
134     struct tnode	*const1;
135     struct tnode	*const2;
136 } RANG_TY;
137 typedef struct		/* T_TYCRANG */
138 {
139     int			 line_no;
140     struct tnode	*lwb_var;
141     struct tnode	*upb_var;
142     struct tnode	*type;
143 } CRANG_TY;
144 typedef struct		/* T_TYARY, T_TYCARY */
145 {
146     int			 line_no;
147     struct tnode	*type_list;
148     struct tnode	*type;
149 } ARY_TY;
150 typedef struct		/* T_TYVARNT */
151 {
152     int 		 line_no;
153     struct tnode	*const_list;
154     struct tnode	*fld_list;
155 } TYVARNT;
156 typedef struct		/* T_TYVARPT */
157 {
158     int			 line_no;
159     char		*cptr;
160     struct tnode	*type_id;
161     struct tnode	*var_list;
162 } VARPT;
163 typedef struct		/* T_CSTAT */
164 {
165     int 		 line_no;
166     struct tnode	*const_list;
167     struct tnode	*stmnt;
168 } C_STMNT;
169 typedef struct		/* T_BSTL, T_BLOCK */
170 {
171     int			line_no;
172     struct tnode	*stmnt_list;
173 } STMNT_BLCK;
174 typedef struct		/* T_FLDLST */
175 {
176     int 		line_no;
177     struct tnode	*fix_list;
178     struct tnode	*variant;
179 } FLDLST;
180 typedef struct		/* T_RFIELD */
181 {
182     int			line_no;
183     struct tnode	*id_list;
184     struct tnode	*type;
185 } RFIELD;
186 typedef struct		/* T_LABEL */
187 {
188     int 		line_no;
189     char		*lbl_ptr;
190     struct tnode	*stmnt;
191 } LABEL_NODE;
192 typedef struct		/* T_GOTO */
193 {
194     int		line_no;
195     char	*lbl_ptr;
196 } GOTO_NODE;
197 typedef struct		/* T_PCALL, T_FCALL */
198 {
199     int			line_no;
200     char		*proc_id;
201     struct tnode	*arg;
202 } PCALL_NODE;
203 typedef struct		/* T_CASE, T_WHILE */
204 {
205     int			line_no;
206     struct tnode	*expr;
207     struct tnode	*stmnt_list;
208 } WHI_CAS;
209 typedef struct		/* T_WITH */
210 {
211     int			line_no;
212     struct tnode	*var_list;
213     struct tnode	*stmnt;
214 } WITH_NODE;
215 typedef struct		/* T_REPEAT */
216 {
217     int			line_no;
218     struct tnode	*stmnt_list;
219     struct tnode	*term_expr;
220 } REPEAT;
221 typedef struct		/* T_RANG */
222 {
223     struct tnode	*expr1;
224     struct tnode	*expr2;
225 } RANG;
226 typedef struct		/* T_CSET */
227 {
228     int			const_tag;
229     struct tnode	*el_list;
230 } CSET_NODE;
231 typedef struct		/* T_ARY */
232 {
233     struct tnode	*expr_list;
234 } ARY_NODE;
235 typedef struct		/* T_WEXPR */
236 {
237     struct tnode	*expr1;
238     struct tnode	*expr2;
239     struct tnode	*expr3;
240 } WEXPR_NODE;
241 typedef struct		/* T_TYID */
242 {
243     int			line_no;
244     char		*idptr;
245 } TYID_NODE;
246 typedef struct		/* anything with linenumber in first field */
247 {
248     int			line_no;
249 } LINED;
250 
251 struct tnode
252 {
253     int tag;
254     union
255     {
256 	FOR_NODE	t_for_node;
257 	ASG_NODE	t_asg_node;
258 	VAR_NODE	t_var_node;
259 	EXPR_NODE	t_expr_node;
260 	LIST_NODE	t_list_node;
261 	IF_NODE		t_if_node;
262 	UN_EXPR		t_un_expr;
263 	P_DEC		t_p_dec;
264 	PARAM		t_param;
265 	PFUNC_NODE	t_pfunc_node;
266 	NIL_NODE	t_nil_node;
267 	CONST_NODE	t_const_node;
268 	CHAR_CONST	t_char_const;
269 	SIGN_CONST	t_sign_const;
270 	COMP_TY		t_comp_ty;
271 	PTR_TY		t_ptr_ty;
272 	RANG_TY		t_rang_ty;
273 	CRANG_TY	t_crang_ty;
274 	ARY_TY		t_ary_ty;
275 	VARPT		t_varpt;
276 	TYVARNT		t_tyvarnt;
277 	C_STMNT		t_c_stmnt;
278 	STMNT_BLCK	t_stmnt_blck;
279 	FLDLST		t_fldlst;
280 	RFIELD		t_rfield;
281 	LABEL_NODE	t_label_node;
282 	PCALL_NODE	t_pcall_node;
283 	WHI_CAS		t_whi_cas;
284 	WITH_NODE	t_with_node;
285 	REPEAT		t_repeat;
286 	RANG		t_rang;
287 	CSET_NODE	t_cset_node;
288 	ARY_NODE	t_ary_node;
289 	WEXPR_NODE	t_wexpr_node;
290 	FIELD_NODE	t_field_node;
291 	TYID_NODE	t_tyid_node;
292 	LINED		t_lined;
293 	GOTO_NODE	t_goto_node;
294     } tree_ele;
295 };
296 
297 #define	for_node		tree_ele.t_for_node
298 #define	asg_node		tree_ele.t_asg_node
299 #define	var_node		tree_ele.t_var_node
300 #define	expr_node		tree_ele.t_expr_node
301 #define	list_node tree_ele.t_list_node
302 #define	if_node			tree_ele.t_if_node
303 #define	un_expr			tree_ele.t_un_expr
304 #define	p_dec			tree_ele.t_p_dec
305 #define	param			tree_ele.t_param
306 #define	pfunc_node		tree_ele.t_pfunc_node
307 #define	nil_node		tree_ele.t_nil_node
308 #define	const_node		tree_ele.t_const_node
309 #define	char_const		tree_ele.t_char_const
310 #define	sign_const		tree_ele.t_sign_const
311 #define	comp_ty			tree_ele.t_comp_ty
312 #define	ptr_ty			tree_ele.t_ptr_ty
313 #define	rang_ty			tree_ele.t_rang_ty
314 #define	crang_ty		tree_ele.t_crang_ty
315 #define	ary_ty			tree_ele.t_ary_ty
316 #define	varpt			tree_ele.t_varpt
317 #define	tyvarnt			tree_ele.t_tyvarnt
318 #define	c_stmnt			tree_ele.t_c_stmnt
319 #define	stmnt_blck		tree_ele.t_stmnt_blck
320 #define	fldlst			tree_ele.t_fldlst
321 #define	rfield			tree_ele.t_rfield
322 #define	label_node		tree_ele.t_label_node
323 #define	pcall_node		tree_ele.t_pcall_node
324 #define	whi_cas			tree_ele.t_whi_cas
325 #define	with_node		tree_ele.t_with_node
326 #define	repeat			tree_ele.t_repeat
327 #define	rang			tree_ele.t_rang
328 #define	cset_node		tree_ele.t_cset_node
329 #define	ary_node		tree_ele.t_ary_node
330 #define	wexpr_node		tree_ele.t_wexpr_node
331 #define	field_node		tree_ele.t_field_node
332 #define	tyid_node		tree_ele.t_tyid_node
333 #define	lined			tree_ele.t_lined
334 #define	goto_node		tree_ele.t_goto_node
335