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