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