summaryrefslogtreecommitdiff
path: root/ghc/utils/ugen/tree.h
blob: 83bab360d2394551a7a2997b2a5bde463829fa5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
#ifndef tree_defined
#define tree_defined

#include <stdio.h>

#ifndef PROTO
#ifdef __STDC__
#define PROTO(x) x
#else
#define PROTO(x) /**/
#endif
#endif

typedef enum {
	typdef,
	deflist,
	def,
	itemlist,
	emitemlist,
	item
} Ttree;

typedef struct { Ttree tag; } *tree;

#ifdef __GNUC__
Ttree ttree(tree t);
extern __inline__ Ttree ttree(tree t)
{
	return(t -> tag);
}
#else  /* ! __GNUC__ */
extern Ttree ttree PROTO((tree));
#endif /* ! __GNUC__ */

struct Stypdef {
	Ttree tag;
	id Xgtid;
	tree Xgtdeflist;
};

struct Sdeflist {
	Ttree tag;
	tree Xgdeflist;
	tree Xgdef;
};

struct Sdef {
	Ttree tag;
	id Xgdid;
	tree Xgditemlist;
};

struct Sitemlist {
	Ttree tag;
	tree Xgitemlist;
	tree Xgitem;
};

struct Semitemlist {
	Ttree tag;
};

struct Sitem {
	Ttree tag;
	id Xgitemfunid;
	id Xgitemtypid;
};

extern tree mktypdef PROTO((id, tree));
#ifdef __GNUC__

id *Rgtid PROTO((struct Stypdef *));

extern __inline__ id *Rgtid(struct Stypdef *t)
{
#ifdef UGEN_DEBUG
	if(t -> tag != typdef)
		fprintf(stderr,"gtid: illegal selection; was %d\n", t -> tag);
#endif /* UGEN_DEBUG */
	return(& t -> Xgtid);
}
#else  /* ! __GNUC__ */
extern id *Rgtid PROTO((struct Stypdef *));
#endif /* ! __GNUC__ */

#define gtid(xyzxyz) (*Rgtid((struct Stypdef *) (xyzxyz)))
#ifdef __GNUC__

tree *Rgtdeflist PROTO((struct Stypdef *));

extern __inline__ tree *Rgtdeflist(struct Stypdef *t)
{
#ifdef UGEN_DEBUG
	if(t -> tag != typdef)
		fprintf(stderr,"gtdeflist: illegal selection; was %d\n", t -> tag);
#endif /* UGEN_DEBUG */
	return(& t -> Xgtdeflist);
}
#else  /* ! __GNUC__ */
extern tree *Rgtdeflist PROTO((struct Stypdef *));
#endif /* ! __GNUC__ */

#define gtdeflist(xyzxyz) (*Rgtdeflist((struct Stypdef *) (xyzxyz)))

extern tree mkdeflist PROTO((tree, tree));
#ifdef __GNUC__

tree *Rgdeflist PROTO((struct Sdeflist *));

extern __inline__ tree *Rgdeflist(struct Sdeflist *t)
{
#ifdef UGEN_DEBUG
	if(t -> tag != deflist)
		fprintf(stderr,"gdeflist: illegal selection; was %d\n", t -> tag);
#endif /* UGEN_DEBUG */
	return(& t -> Xgdeflist);
}
#else  /* ! __GNUC__ */
extern tree *Rgdeflist PROTO((struct Sdeflist *));
#endif /* ! __GNUC__ */

#define gdeflist(xyzxyz) (*Rgdeflist((struct Sdeflist *) (xyzxyz)))
#ifdef __GNUC__

tree *Rgdef PROTO((struct Sdeflist *));

extern __inline__ tree *Rgdef(struct Sdeflist *t)
{
#ifdef UGEN_DEBUG
	if(t -> tag != deflist)
		fprintf(stderr,"gdef: illegal selection; was %d\n", t -> tag);
#endif /* UGEN_DEBUG */
	return(& t -> Xgdef);
}
#else  /* ! __GNUC__ */
extern tree *Rgdef PROTO((struct Sdeflist *));
#endif /* ! __GNUC__ */

#define gdef(xyzxyz) (*Rgdef((struct Sdeflist *) (xyzxyz)))

extern tree mkdef PROTO((id, tree));
#ifdef __GNUC__

id *Rgdid PROTO((struct Sdef *));

extern __inline__ id *Rgdid(struct Sdef *t)
{
#ifdef UGEN_DEBUG
	if(t -> tag != def)
		fprintf(stderr,"gdid: illegal selection; was %d\n", t -> tag);
#endif /* UGEN_DEBUG */
	return(& t -> Xgdid);
}
#else  /* ! __GNUC__ */
extern id *Rgdid PROTO((struct Sdef *));
#endif /* ! __GNUC__ */

#define gdid(xyzxyz) (*Rgdid((struct Sdef *) (xyzxyz)))
#ifdef __GNUC__

tree *Rgditemlist PROTO((struct Sdef *));

extern __inline__ tree *Rgditemlist(struct Sdef *t)
{
#ifdef UGEN_DEBUG
	if(t -> tag != def)
		fprintf(stderr,"gditemlist: illegal selection; was %d\n", t -> tag);
#endif /* UGEN_DEBUG */
	return(& t -> Xgditemlist);
}
#else  /* ! __GNUC__ */
extern tree *Rgditemlist PROTO((struct Sdef *));
#endif /* ! __GNUC__ */

#define gditemlist(xyzxyz) (*Rgditemlist((struct Sdef *) (xyzxyz)))

extern tree mkitemlist PROTO((tree, tree));
#ifdef __GNUC__

tree *Rgitemlist PROTO((struct Sitemlist *));

extern __inline__ tree *Rgitemlist(struct Sitemlist *t)
{
#ifdef UGEN_DEBUG
	if(t -> tag != itemlist)
		fprintf(stderr,"gitemlist: illegal selection; was %d\n", t -> tag);
#endif /* UGEN_DEBUG */
	return(& t -> Xgitemlist);
}
#else  /* ! __GNUC__ */
extern tree *Rgitemlist PROTO((struct Sitemlist *));
#endif /* ! __GNUC__ */

#define gitemlist(xyzxyz) (*Rgitemlist((struct Sitemlist *) (xyzxyz)))
#ifdef __GNUC__

tree *Rgitem PROTO((struct Sitemlist *));

extern __inline__ tree *Rgitem(struct Sitemlist *t)
{
#ifdef UGEN_DEBUG
	if(t -> tag != itemlist)
		fprintf(stderr,"gitem: illegal selection; was %d\n", t -> tag);
#endif /* UGEN_DEBUG */
	return(& t -> Xgitem);
}
#else  /* ! __GNUC__ */
extern tree *Rgitem PROTO((struct Sitemlist *));
#endif /* ! __GNUC__ */

#define gitem(xyzxyz) (*Rgitem((struct Sitemlist *) (xyzxyz)))

extern tree mkemitemlist PROTO((void));

extern tree mkitem PROTO((id, id));
#ifdef __GNUC__

id *Rgitemfunid PROTO((struct Sitem *));

extern __inline__ id *Rgitemfunid(struct Sitem *t)
{
#ifdef UGEN_DEBUG
	if(t -> tag != item)
		fprintf(stderr,"gitemfunid: illegal selection; was %d\n", t -> tag);
#endif /* UGEN_DEBUG */
	return(& t -> Xgitemfunid);
}
#else  /* ! __GNUC__ */
extern id *Rgitemfunid PROTO((struct Sitem *));
#endif /* ! __GNUC__ */

#define gitemfunid(xyzxyz) (*Rgitemfunid((struct Sitem *) (xyzxyz)))
#ifdef __GNUC__

id *Rgitemtypid PROTO((struct Sitem *));

extern __inline__ id *Rgitemtypid(struct Sitem *t)
{
#ifdef UGEN_DEBUG
	if(t -> tag != item)
		fprintf(stderr,"gitemtypid: illegal selection; was %d\n", t -> tag);
#endif /* UGEN_DEBUG */
	return(& t -> Xgitemtypid);
}
#else  /* ! __GNUC__ */
extern id *Rgitemtypid PROTO((struct Sitem *));
#endif /* ! __GNUC__ */

#define gitemtypid(xyzxyz) (*Rgitemtypid((struct Sitem *) (xyzxyz)))

#endif