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