3 TREELANG Compiler common definitions (treelang.h)
5 Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002, 2003, 2004
6 Free Software Foundation, Inc.
8 This program is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 2, or (at your option) any
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA.
23 In other words, you are welcome to use, share and improve this program.
24 You are forbidden to forbid anyone else to use, share and improve
25 what you give them. Help stamp out software-hoarding!
27 ---------------------------------------------------------------------------
29 Written by Tim Josling 1999, 2000, 2001, based in part on other
30 parts of the GCC compiler.
36 /* Parse structure type. */
38 { /* These values less likely to be there by chance unlike 0/1,
39 make checks more meaningful */
41 production_category
= 222,
42 parameter_category
= 333
45 /* Input file FILE. */
48 /* Forward references to satisfy mutually recursive definitions. */
50 struct production_part
;
51 struct prod_token_parm_item
;
52 typedef struct prod_token_parm_item item
;
54 /* A token from the input file. */
56 struct token_part
GTY(())
60 unsigned int length
; /* The value. */
64 /* Definitions for fields in production. */
65 #define NESTING_LEVEL(a) a->tp.pro.info[0] /* Level used for variable definitions. */
66 /* Numeric type used in type definitions and expressions. */
67 #define NUMERIC_TYPE(a) a->tp.pro.info[1]
69 #define SYMBOL_TABLE_NAME(a) (a->tp.pro.sub[0]) /* Name token. */
70 #define EXPRESSION_TYPE(a) (a->tp.pro.sub[1]) /* Type identifier. */
71 #define OP1(a) (a->tp.pro.sub[2]) /* Exp operand1. */
72 #define PARAMETERS(a) (a->tp.pro.sub[2]) /* Function parameters. */
73 #define VARIABLE(a) (a->tp.pro.sub[2]) /* Parameter variable ptr. */
74 #define VAR_INIT(a) (a->tp.pro.sub[2]) /* Variable init. */
75 #define OP2(a) (a->tp.pro.sub[3]) /* Exp operand2. */
76 /* Function parameters linked via struct tree_parameter_list. */
77 #define FIRST_PARMS(a) (a->tp.pro.sub[3])
78 #define OP3(a) (a->tp.pro.sub[4]) /* Exp operand3. */
79 #define STORAGE_CLASS_TOKEN(a) (a->tp.pro.sub[4]) /* Storage class token. */
80 #define STORAGE_CLASS(a) a->tp.pro.flag1 /* Values in treetree.h. */
82 struct production_part
GTY(())
84 struct prod_token_parm_item
*main_token
; /* Main token for error msgs; variable name token. */
86 unsigned int info
[2]; /* Extra information. */
88 struct prod_token_parm_item
*sub
[SUB_COUNT
]; /* Sub productions or tokens. */
89 tree code
; /* Back end hook for this item. */
90 struct prod_token_parm_item
*next
; /* Next in chains of various types. */
103 #define STATIC_STORAGE 0
104 #define AUTOMATIC_STORAGE 1
105 #define EXTERNAL_REFERENCE_STORAGE 2
106 #define EXTERNAL_DEFINITION_STORAGE 3
109 #define SIGNED_CHAR 1
110 #define UNSIGNED_CHAR 2
112 #define UNSIGNED_INT 4
115 /* Expression types. */
116 #define EXP_PLUS 0 /* Addition expression. */
117 #define EXP_REFERENCE 1 /* Variable reference. */
118 #define EXP_ASSIGN 2 /* Assignment. */
119 #define EXP_FUNCTION_INVOCATION 3 /* Call function. */
120 #define EXP_MINUS 4 /* Subtraction. */
121 #define EXP_EQUALS 5 /* Equality test. */
123 /* Parameter list passed to back end. */
124 struct parameter_part
GTY(())
126 struct prod_token_parm_item
*next
; /* Next entry. */
127 unsigned char* variable_name
; /* Name. */
128 tree
* GTY ((skip
)) where_to_put_var_tree
; /* Where to save decl. */
131 /* A production or a token. */
132 struct prod_token_parm_item
GTY(())
134 enum category_enum category
; /* Token or production. */
135 unsigned int type
; /* Token or production type. */
138 struct token_part
GTY((tag ("token_category"))) tok
;
139 struct production_part
GTY((tag ("production_category"))) pro
;
140 struct parameter_part
GTY((tag ("parameter_category"))) par
;
141 } GTY((desc ("((item *)&%1)->category"))) tp
;
145 /* For parser. Alternatively you can define it using %union (bison) or
147 #define YYSTYPE void *
149 void *my_malloc (size_t size
);
150 int insert_tree_name (struct prod_token_parm_item
*prod
);
151 struct prod_token_parm_item
*lookup_tree_name (struct prod_token_parm_item
*prod
);
152 struct prod_token_parm_item
*make_production (int type
, struct prod_token_parm_item
*main_tok
);
153 void mark_production_used (struct prod_token_parm_item
*pp
);
154 void mark_token_used (struct prod_token_parm_item
*tt
);
155 void treelang_debug (void);
157 void sanity_check (struct prod_token_parm_item
*item
);