home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / usr.bin / pascal / src / tree_ty.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-16  |  8.9 KB  |  362 lines

  1. /*-
  2.  * Copyright (c) 1980 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  *    @(#)tree_ty.h    5.2 (Berkeley) 4/16/91
  34.  */
  35.  
  36. typedef struct /* T_FORU, T_FORD */
  37. {
  38.     int        line_no;     /* line number of for */
  39.     struct    tnode    *init_asg;    /* initialization */
  40.     struct    tnode    *term_expr;    /* termination expresssion */
  41.     struct    tnode    *for_stmnt;    /* for statement */
  42. } FOR_NODE;
  43. typedef struct  /* T_ASGN */
  44. {
  45.     int        line_no;    /* line number of := */
  46.     struct    tnode    *lhs_var;
  47.     struct    tnode    *rhs_expr;
  48. } ASG_NODE;
  49. #ifndef PTREE
  50. typedef struct                /* T_VAR */
  51. {
  52.     int         line_no;
  53.     char        *cptr;
  54.     struct tnode    *qual;        /* list node */
  55. } VAR_NODE;
  56. typedef struct        /* T_FIELD */
  57. {
  58.     char        *id_ptr;
  59.     struct tnode    *other;        
  60. } FIELD_NODE;
  61. #else
  62. typedef struct                /* T_VAR */
  63. {
  64.     int         line_no;
  65.     char        *cptr;
  66.     struct tnode    *qual;
  67.     struct nl        *nl_entry;
  68. } VAR_NODE;
  69. typedef struct        /* T_FIELD */
  70. {
  71.     char        *id_ptr;
  72.     struct tnode    *other;        
  73.     struct nl        *nl_entry;
  74. } FIELD_NODE;
  75. #endif
  76. typedef struct                /* T_MOD, T_MULT, T_DIVD, T_DIV,
  77.                        T_AND, T_ADD, T_SUB, T_OR,
  78.                        T_EQ, T_LT, T_GT, T_NE, T_LE
  79.                        T_GE, T_IN */
  80. {
  81.     int        const_tag;
  82.     struct    tnode    *lhs;
  83.     struct    tnode    *rhs;
  84. } EXPR_NODE;
  85. typedef struct            /* T_LISTPP */
  86. {
  87.     struct tnode *list;  /* check the types on these,
  88.                 this is used in pclvalue and lvalue */
  89.     struct tnode *next;
  90. } LIST_NODE;
  91. typedef struct            /* T_IF, T_IFEL, T_IFX */
  92. {
  93.     int           line_no;
  94.     struct tnode *cond_expr;
  95.     struct tnode *then_stmnt;
  96.     struct tnode *else_stmnt;
  97. } IF_NODE;
  98. typedef struct            /* T_MINUS, T_PLUS, T_NOT */
  99. {
  100.     int        const_tag;
  101.     struct tnode     *expr;
  102. } UN_EXPR;
  103. typedef struct /* T_PDEC, T_FDEC, T_PROG */
  104. {
  105.     int    line_no;
  106.     char    *id_ptr;
  107.     struct tnode    *param_list;
  108.     struct tnode    *type;
  109. } P_DEC;
  110. typedef struct    /* T_PVAL, T_PVAR */
  111. {
  112.     struct tnode    *id_list;
  113.     struct tnode    *type;
  114. } PARAM;
  115. typedef struct        /* T_PFUNC, T_PPROC */
  116. {
  117.     struct tnode    *id_list,
  118.             *type,
  119.             *param_list;
  120.     int            line_no;
  121. } PFUNC_NODE;
  122. typedef struct        /* T_NIL */
  123. {
  124.     int    const_tag;
  125. } NIL_NODE;
  126. typedef struct        /* T_STRNG, T_INT, T_FINT, T_BINT */
  127. {
  128.     int        const_tag;
  129.     char    *cptr;
  130. } CONST_NODE;
  131. typedef struct        /* T_CSTRNG, T_ID, T_CFINT, T_CINT, T_CBINT */
  132. {
  133.     char    *cptr;
  134. } CHAR_CONST;
  135. typedef struct        /* T_PLUSC, T_MINUSC */
  136. {
  137.     struct tnode    *number;
  138. } SIGN_CONST;
  139. #ifdef PTREE
  140. typedef struct
  141. {
  142.     int    line_no
  143.     struct tnode    *type;
  144.     struct nl        *nl_entry;
  145. } COMP_TY;
  146. #else
  147. typedef struct        /* T_TYPACK, T_TYSCAL, T_TYFILE, T_TYSET, T_TYREC */
  148. {
  149.     int          line_no;
  150.     struct tnode *type;
  151. } COMP_TY;
  152. #endif
  153. typedef struct        /* T_TYPTR */
  154. {
  155.     int             line_no;
  156.     struct tnode    *id_node;
  157. } PTR_TY;
  158. typedef struct        /* T_TYRANG */
  159. {
  160.     int             line_no;
  161.     struct tnode    *const1;
  162.     struct tnode    *const2;
  163. } RANG_TY;
  164. typedef struct        /* T_TYCRANG */
  165. {
  166.     int             line_no;
  167.     struct tnode    *lwb_var;
  168.     struct tnode    *upb_var;
  169.     struct tnode    *type;
  170. } CRANG_TY;
  171. typedef struct        /* T_TYARY, T_TYCARY */
  172. {
  173.     int             line_no;
  174.     struct tnode    *type_list;
  175.     struct tnode    *type;
  176. } ARY_TY;
  177. typedef struct        /* T_TYVARNT */
  178. {
  179.     int          line_no;
  180.     struct tnode    *const_list;
  181.     struct tnode    *fld_list;
  182. } TYVARNT;
  183. typedef struct        /* T_TYVARPT */
  184. {
  185.     int             line_no;
  186.     char        *cptr;
  187.     struct tnode    *type_id;
  188.     struct tnode    *var_list;
  189. } VARPT;
  190. typedef struct        /* T_CSTAT */
  191. {
  192.     int          line_no;
  193.     struct tnode    *const_list;
  194.     struct tnode    *stmnt;
  195. } C_STMNT;
  196. typedef struct        /* T_BSTL, T_BLOCK */
  197. {
  198.     int            line_no;
  199.     struct tnode    *stmnt_list;
  200. } STMNT_BLCK;
  201. typedef struct        /* T_FLDLST */
  202. {
  203.     int         line_no;
  204.     struct tnode    *fix_list;
  205.     struct tnode    *variant;
  206. } FLDLST;
  207. typedef struct        /* T_RFIELD */
  208. {
  209.     int            line_no;
  210.     struct tnode    *id_list;
  211.     struct tnode    *type;
  212. } RFIELD;
  213. typedef struct        /* T_LABEL */
  214. {
  215.     int         line_no;
  216.     char        *lbl_ptr;
  217.     struct tnode    *stmnt;
  218. } LABEL_NODE;
  219. typedef struct        /* T_GOTO */
  220. {
  221.     int        line_no;
  222.     char    *lbl_ptr;
  223. } GOTO_NODE;
  224. typedef struct        /* T_PCALL, T_FCALL */
  225. {
  226.     int            line_no;
  227.     char        *proc_id;
  228.     struct tnode    *arg;
  229. } PCALL_NODE;
  230. typedef struct        /* T_CASE, T_WHILE */
  231. {
  232.     int            line_no;
  233.     struct tnode    *expr;
  234.     struct tnode    *stmnt_list;
  235. } WHI_CAS;
  236. typedef struct        /* T_WITH */
  237. {
  238.     int            line_no;
  239.     struct tnode    *var_list;
  240.     struct tnode    *stmnt;
  241. } WITH_NODE;
  242. typedef struct        /* T_REPEAT */
  243. {
  244.     int            line_no;
  245.     struct tnode    *stmnt_list;
  246.     struct tnode    *term_expr;
  247. } REPEAT;
  248. typedef struct        /* T_RANG */
  249. {
  250.     struct tnode    *expr1;
  251.     struct tnode    *expr2;
  252. } RANG;
  253. typedef struct        /* T_CSET */
  254. {
  255.     int            const_tag;
  256.     struct tnode    *el_list;
  257. } CSET_NODE;
  258. typedef struct        /* T_ARY */
  259. {
  260.     struct tnode    *expr_list;
  261. } ARY_NODE;
  262. typedef struct        /* T_WEXPR */
  263. {
  264.     struct tnode    *expr1;
  265.     struct tnode    *expr2;
  266.     struct tnode    *expr3;
  267. } WEXPR_NODE;
  268. typedef struct        /* T_TYID */
  269. {
  270.     int            line_no;
  271.     char        *idptr;
  272. } TYID_NODE;
  273. typedef struct        /* anything with linenumber in first field */
  274. {
  275.     int            line_no;
  276. } LINED;
  277.  
  278. struct tnode
  279. {
  280.     int tag;
  281.     union
  282.     {
  283.     FOR_NODE    t_for_node;    
  284.     ASG_NODE    t_asg_node;
  285.     VAR_NODE    t_var_node;
  286.     EXPR_NODE    t_expr_node;
  287.     LIST_NODE    t_list_node;
  288.     IF_NODE        t_if_node;
  289.     UN_EXPR        t_un_expr;
  290.     P_DEC        t_p_dec;
  291.     PARAM        t_param;
  292.     PFUNC_NODE    t_pfunc_node;
  293.     NIL_NODE    t_nil_node;
  294.     CONST_NODE    t_const_node;
  295.     CHAR_CONST    t_char_const;
  296.     SIGN_CONST    t_sign_const;
  297.     COMP_TY        t_comp_ty;
  298.     PTR_TY        t_ptr_ty;
  299.     RANG_TY        t_rang_ty;
  300.     CRANG_TY    t_crang_ty;
  301.     ARY_TY        t_ary_ty;
  302.     VARPT        t_varpt;
  303.     TYVARNT        t_tyvarnt;
  304.     C_STMNT        t_c_stmnt;
  305.     STMNT_BLCK    t_stmnt_blck;
  306.     FLDLST        t_fldlst;
  307.     RFIELD        t_rfield;
  308.     LABEL_NODE    t_label_node;
  309.     PCALL_NODE    t_pcall_node;
  310.     WHI_CAS        t_whi_cas;
  311.     WITH_NODE    t_with_node;
  312.     REPEAT        t_repeat;
  313.     RANG        t_rang;
  314.     CSET_NODE    t_cset_node;
  315.     ARY_NODE    t_ary_node;
  316.     WEXPR_NODE    t_wexpr_node;
  317.     FIELD_NODE    t_field_node;
  318.     TYID_NODE    t_tyid_node;
  319.     LINED        t_lined;
  320.     GOTO_NODE    t_goto_node;
  321.     } tree_ele;
  322. };
  323.  
  324. #define    for_node        tree_ele.t_for_node    
  325. #define    asg_node        tree_ele.t_asg_node
  326. #define    var_node        tree_ele.t_var_node
  327. #define    expr_node        tree_ele.t_expr_node
  328. #define    list_node tree_ele.t_list_node
  329. #define    if_node            tree_ele.t_if_node
  330. #define    un_expr            tree_ele.t_un_expr
  331. #define    p_dec            tree_ele.t_p_dec
  332. #define    param            tree_ele.t_param
  333. #define    pfunc_node        tree_ele.t_pfunc_node
  334. #define    nil_node        tree_ele.t_nil_node
  335. #define    const_node        tree_ele.t_const_node
  336. #define    char_const        tree_ele.t_char_const
  337. #define    sign_const        tree_ele.t_sign_const
  338. #define    comp_ty            tree_ele.t_comp_ty
  339. #define    ptr_ty            tree_ele.t_ptr_ty
  340. #define    rang_ty            tree_ele.t_rang_ty
  341. #define    crang_ty        tree_ele.t_crang_ty
  342. #define    ary_ty            tree_ele.t_ary_ty
  343. #define    varpt            tree_ele.t_varpt
  344. #define    tyvarnt            tree_ele.t_tyvarnt
  345. #define    c_stmnt            tree_ele.t_c_stmnt
  346. #define    stmnt_blck        tree_ele.t_stmnt_blck
  347. #define    fldlst            tree_ele.t_fldlst
  348. #define    rfield            tree_ele.t_rfield
  349. #define    label_node        tree_ele.t_label_node
  350. #define    pcall_node        tree_ele.t_pcall_node
  351. #define    whi_cas            tree_ele.t_whi_cas
  352. #define    with_node        tree_ele.t_with_node
  353. #define    repeat            tree_ele.t_repeat
  354. #define    rang            tree_ele.t_rang
  355. #define    cset_node        tree_ele.t_cset_node
  356. #define    ary_node        tree_ele.t_ary_node
  357. #define    wexpr_node        tree_ele.t_wexpr_node
  358. #define    field_node        tree_ele.t_field_node
  359. #define    tyid_node        tree_ele.t_tyid_node
  360. #define    lined            tree_ele.t_lined
  361. #define    goto_node        tree_ele.t_goto_node
  362.