]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/treelang/treelang.h
patch_tester.sh (usage): Watermark is not lexicographic.
[thirdparty/gcc.git] / gcc / treelang / treelang.h
CommitLineData
edf06e44
NC
1/* TREELANG Compiler common definitions (treelang.h)
2
3 Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002, 2003, 2004,
4 2007 Free Software Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 3, or (at your option) any
9 later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>.
19
20 In other words, you are welcome to use, share and improve this program.
21 You are forbidden to forbid anyone else to use, share and improve
22 what you give them. Help stamp out software-hoarding!
23
24 ---------------------------------------------------------------------------
25
26 Written by Tim Josling 1999, 2000, 2001, based in part on other
27 parts of the GCC compiler. */
6cfea11b 28
c2e39602
NS
29#include "input.h"
30
6cfea11b
TJ
31/* Parse structure type. */
32enum category_enum
33{ /* These values less likely to be there by chance unlike 0/1,
34 make checks more meaningful */
35 token_category = 111,
96e3ac4f
TJ
36 production_category = 222,
37 parameter_category = 333
6cfea11b
TJ
38};
39
c2e39602 40/* Input file FILE. */
6cfea11b
TJ
41extern FILE* yyin;
42
96e3ac4f
TJ
43/* Forward references to satisfy mutually recursive definitions. */
44struct token_part;
45struct production_part;
46struct prod_token_parm_item;
352a77c8 47typedef struct prod_token_parm_item item;
6cfea11b 48
96e3ac4f
TJ
49/* A token from the input file. */
50
51struct token_part GTY(())
6cfea11b 52{
c2e39602 53 location_t location;
6cfea11b
TJ
54 unsigned int charno;
55 unsigned int length; /* The value. */
d426d208 56 const unsigned char *chars;
6cfea11b
TJ
57};
58
96e3ac4f
TJ
59/* Definitions for fields in production. */
60#define NESTING_LEVEL(a) a->tp.pro.info[0] /* Level used for variable definitions. */
886c07bc
TJ
61/* Numeric type used in type definitions and expressions. */
62#define NUMERIC_TYPE(a) a->tp.pro.info[1]
96e3ac4f
TJ
63#define SUB_COUNT 5
64#define SYMBOL_TABLE_NAME(a) (a->tp.pro.sub[0]) /* Name token. */
65#define EXPRESSION_TYPE(a) (a->tp.pro.sub[1]) /* Type identifier. */
66#define OP1(a) (a->tp.pro.sub[2]) /* Exp operand1. */
67#define PARAMETERS(a) (a->tp.pro.sub[2]) /* Function parameters. */
68#define VARIABLE(a) (a->tp.pro.sub[2]) /* Parameter variable ptr. */
69#define VAR_INIT(a) (a->tp.pro.sub[2]) /* Variable init. */
70#define OP2(a) (a->tp.pro.sub[3]) /* Exp operand2. */
886c07bc
TJ
71/* Function parameters linked via struct tree_parameter_list. */
72#define FIRST_PARMS(a) (a->tp.pro.sub[3])
96e3ac4f
TJ
73#define OP3(a) (a->tp.pro.sub[4]) /* Exp operand3. */
74#define STORAGE_CLASS_TOKEN(a) (a->tp.pro.sub[4]) /* Storage class token. */
75#define STORAGE_CLASS(a) a->tp.pro.flag1 /* Values in treetree.h. */
76
77struct production_part GTY(())
6cfea11b 78{
96e3ac4f 79 struct prod_token_parm_item *main_token; /* Main token for error msgs; variable name token. */
6cfea11b
TJ
80
81 unsigned int info[2]; /* Extra information. */
6cfea11b 82
96e3ac4f
TJ
83 struct prod_token_parm_item *sub[SUB_COUNT]; /* Sub productions or tokens. */
84 tree code; /* Back end hook for this item. */
85 struct prod_token_parm_item *next; /* Next in chains of various types. */
6cfea11b
TJ
86
87 unsigned int flag1:2;
6cfea11b
TJ
88 unsigned int flag2:1;
89 unsigned int flag3:1;
90 unsigned int flag4:1;
91 unsigned int flag5:1;
92 unsigned int flag6:1;
93 unsigned int flag7:1;
94
95};
96
96e3ac4f
TJ
97/* Storage modes. */
98#define STATIC_STORAGE 0
99#define AUTOMATIC_STORAGE 1
100#define EXTERNAL_REFERENCE_STORAGE 2
101#define EXTERNAL_DEFINITION_STORAGE 3
102
103/* Numeric types. */
104#define SIGNED_CHAR 1
105#define UNSIGNED_CHAR 2
106#define SIGNED_INT 3
107#define UNSIGNED_INT 4
108#define VOID_TYPE 5
109
110/* Expression types. */
111#define EXP_PLUS 0 /* Addition expression. */
112#define EXP_REFERENCE 1 /* Variable reference. */
113#define EXP_ASSIGN 2 /* Assignment. */
114#define EXP_FUNCTION_INVOCATION 3 /* Call function. */
115#define EXP_MINUS 4 /* Subtraction. */
116#define EXP_EQUALS 5 /* Equality test. */
117
118/* Parameter list passed to back end. */
119struct parameter_part GTY(())
120{
121 struct prod_token_parm_item *next; /* Next entry. */
d426d208 122 const unsigned char *variable_name; /* Name. */
52f9be18 123 tree * GTY ((skip)) where_to_put_var_tree; /* Where to save decl. */
96e3ac4f
TJ
124};
125
126/* A production or a token. */
127struct prod_token_parm_item GTY(())
128{
129 enum category_enum category; /* Token or production. */
130 unsigned int type; /* Token or production type. */
131 union t_or_p
132 {
133 struct token_part GTY((tag ("token_category"))) tok;
134 struct production_part GTY((tag ("production_category"))) pro;
135 struct parameter_part GTY((tag ("parameter_category"))) par;
136 } GTY((desc ("((item *)&%1)->category"))) tp;
137};
138
139
6cfea11b
TJ
140/* For parser. Alternatively you can define it using %union (bison) or
141 union. */
142#define YYSTYPE void *
143
144void *my_malloc (size_t size);
96e3ac4f
TJ
145int insert_tree_name (struct prod_token_parm_item *prod);
146struct prod_token_parm_item *lookup_tree_name (struct prod_token_parm_item *prod);
147struct prod_token_parm_item *make_production (int type, struct prod_token_parm_item *main_tok);
148void mark_production_used (struct prod_token_parm_item *pp);
149void mark_token_used (struct prod_token_parm_item *tt);
6cfea11b
TJ
150void treelang_debug (void);
151
27f94314 152void sanity_check (struct prod_token_parm_item *item);