xref: /csrg-svn/usr.bin/pascal/src/tree_ty.h (revision 15024)
1 /* Copyright (c) 1979 Regents of the University of California */
2 
3 /* static char sccsid[]="@(#)tree_ty.h 1.2 7/1/83"; */
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_TYARY */
134 {
135     int			 line_no;
136     struct tnode	*type_list;
137     struct tnode	*type;
138 } ARY_TY;
139 typedef struct		/* T_TYVARNT */
140 {
141     int 		 line_no;
142     struct tnode	*const_list;
143     struct tnode	*fld_list;
144 } TYVARNT;
145 typedef struct		/* T_TYVARPT */
146 {
147     int			 line_no;
148     char		*cptr;
149     struct tnode	*type_id;
150     struct tnode	*var_list;
151 } VARPT;
152 typedef struct		/* T_CSTAT */
153 {
154     int 		 line_no;
155     struct tnode	*const_list;
156     struct tnode	*stmnt;
157 } C_STMNT;
158 typedef struct		/* T_BSTL, T_BLOCK */
159 {
160     int			line_no;
161     struct tnode	*stmnt_list;
162 } STMNT_BLCK;
163 typedef struct		/* T_FLDLST */
164 {
165     int 		line_no;
166     struct tnode	*fix_list;
167     struct tnode	*variant;
168 } FLDLST;
169 typedef struct		/* T_RFIELD */
170 {
171     int			line_no;
172     struct tnode	*id_list;
173     struct tnode	*type;
174 } RFIELD;
175 typedef struct		/* T_LABEL */
176 {
177     int 		line_no;
178     char		*lbl_ptr;
179     struct tnode	*stmnt;
180 } LABEL_NODE;
181 typedef struct		/* T_GOTO */
182 {
183     int		line_no;
184     char	*lbl_ptr;
185 } GOTO_NODE;
186 typedef struct		/* T_PCALL, T_FCALL */
187 {
188     int			line_no;
189     char		*proc_id;
190     struct tnode	*arg;
191 } PCALL_NODE;
192 typedef struct		/* T_CASE, T_WHILE */
193 {
194     int			line_no;
195     struct tnode	*expr;
196     struct tnode	*stmnt_list;
197 } WHI_CAS;
198 typedef struct		/* T_WITH */
199 {
200     int			line_no;
201     struct tnode	*var_list;
202     struct tnode	*stmnt;
203 } WITH_NODE;
204 typedef struct		/* T_REPEAT */
205 {
206     int			line_no;
207     struct tnode	*stmnt_list;
208     struct tnode	*term_expr;
209 } REPEAT;
210 typedef struct		/* T_RANG */
211 {
212     struct tnode	*expr1;
213     struct tnode	*expr2;
214 } RANG;
215 typedef struct		/* T_CSET */
216 {
217     int			const_tag;
218     struct tnode	*el_list;
219 } CSET_NODE;
220 typedef struct		/* T_ARY */
221 {
222     struct tnode	*expr_list;
223 } ARY_NODE;
224 typedef struct		/* T_WEXPR */
225 {
226     struct tnode	*expr1;
227     struct tnode	*expr2;
228     struct tnode	*expr3;
229 } WEXPR_NODE;
230 typedef struct		/* T_TYID */
231 {
232     int			line_no;
233     char		*idptr;
234 } TYID_NODE;
235 typedef struct		/* anything with linenumber in first field */
236 {
237     int			line_no;
238 } LINED;
239 
240 struct tnode
241 {
242     int tag;
243     union
244     {
245 	FOR_NODE	t_for_node;
246 	ASG_NODE	t_asg_node;
247 	VAR_NODE	t_var_node;
248 	EXPR_NODE	t_expr_node;
249 	LIST_NODE	t_list_node;
250 	IF_NODE		t_if_node;
251 	UN_EXPR		t_un_expr;
252 	P_DEC		t_p_dec;
253 	PARAM		t_param;
254 	PFUNC_NODE	t_pfunc_node;
255 	NIL_NODE	t_nil_node;
256 	CONST_NODE	t_const_node;
257 	CHAR_CONST	t_char_const;
258 	SIGN_CONST	t_sign_const;
259 	COMP_TY		t_comp_ty;
260 	PTR_TY		t_ptr_ty;
261 	RANG_TY		t_rang_ty;
262 	ARY_TY		t_ary_ty;
263 	VARPT		t_varpt;
264 	TYVARNT		t_tyvarnt;
265 	C_STMNT		t_c_stmnt;
266 	STMNT_BLCK	t_stmnt_blck;
267 	FLDLST		t_fldlst;
268 	RFIELD		t_rfield;
269 	LABEL_NODE	t_label_node;
270 	PCALL_NODE	t_pcall_node;
271 	WHI_CAS		t_whi_cas;
272 	WITH_NODE	t_with_node;
273 	REPEAT		t_repeat;
274 	RANG		t_rang;
275 	CSET_NODE	t_cset_node;
276 	ARY_NODE	t_ary_node;
277 	WEXPR_NODE	t_wexpr_node;
278 	FIELD_NODE	t_field_node;
279 	TYID_NODE	t_tyid_node;
280 	LINED		t_lined;
281 	GOTO_NODE	t_goto_node;
282     } tree_ele;
283 };
284 
285 #define	for_node		tree_ele.t_for_node
286 #define	asg_node		tree_ele.t_asg_node
287 #define	var_node		tree_ele.t_var_node
288 #define	expr_node		tree_ele.t_expr_node
289 #define	list_node tree_ele.t_list_node
290 #define	if_node			tree_ele.t_if_node
291 #define	un_expr			tree_ele.t_un_expr
292 #define	p_dec			tree_ele.t_p_dec
293 #define	param			tree_ele.t_param
294 #define	pfunc_node		tree_ele.t_pfunc_node
295 #define	nil_node		tree_ele.t_nil_node
296 #define	const_node		tree_ele.t_const_node
297 #define	char_const		tree_ele.t_char_const
298 #define	sign_const		tree_ele.t_sign_const
299 #define	comp_ty			tree_ele.t_comp_ty
300 #define	ptr_ty			tree_ele.t_ptr_ty
301 #define	rang_ty			tree_ele.t_rang_ty
302 #define	ary_ty			tree_ele.t_ary_ty
303 #define	varpt			tree_ele.t_varpt
304 #define	tyvarnt			tree_ele.t_tyvarnt
305 #define	c_stmnt			tree_ele.t_c_stmnt
306 #define	stmnt_blck		tree_ele.t_stmnt_blck
307 #define	fldlst			tree_ele.t_fldlst
308 #define	rfield			tree_ele.t_rfield
309 #define	label_node		tree_ele.t_label_node
310 #define	pcall_node		tree_ele.t_pcall_node
311 #define	whi_cas			tree_ele.t_whi_cas
312 #define	with_node		tree_ele.t_with_node
313 #define	repeat			tree_ele.t_repeat
314 #define	rang			tree_ele.t_rang
315 #define	cset_node		tree_ele.t_cset_node
316 #define	ary_node		tree_ele.t_ary_node
317 #define	wexpr_node		tree_ele.t_wexpr_node
318 #define	field_node		tree_ele.t_field_node
319 #define	tyid_node		tree_ele.t_tyid_node
320 #define	lined			tree_ele.t_lined
321 #define	goto_node		tree_ele.t_goto_node
322