[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / compiler / yaccParser / ttype.h
1 #ifndef ttype_defined
2 #define ttype_defined
3
4 #include <stdio.h>
5
6 #ifndef PROTO
7 #ifdef __STDC__
8 #define PROTO(x) x
9 #else
10 #define PROTO(x) /**/
11 #endif
12 #endif
13
14 typedef enum {
15         tname,
16         namedtvar,
17         tllist,
18         ttuple,
19         tfun,
20         context,
21         unidict,
22         unityvartemplate,
23         uniforall,
24         ty_maybe_nothing,
25         ty_maybe_just
26 } Tttype;
27
28 typedef struct { Tttype tag; } *ttype;
29
30 #ifdef __GNUC__
31 extern __inline__ Tttype tttype(ttype t)
32 {
33         return(t -> tag);
34 }
35 #else  /* ! __GNUC__ */
36 extern Tttype tttype PROTO((ttype));
37 #endif /* ! __GNUC__ */
38
39 struct Stname {
40         Tttype tag;
41         unkId Xgtypeid;
42         list Xgtypel;
43 };
44
45 struct Snamedtvar {
46         Tttype tag;
47         unkId Xgnamedtvar;
48 };
49
50 struct Stllist {
51         Tttype tag;
52         ttype Xgtlist;
53 };
54
55 struct Sttuple {
56         Tttype tag;
57         list Xgttuple;
58 };
59
60 struct Stfun {
61         Tttype tag;
62         ttype Xgtfun;
63         ttype Xgtarg;
64 };
65
66 struct Scontext {
67         Tttype tag;
68         list Xgtcontextl;
69         ttype Xgtcontextt;
70 };
71
72 struct Sunidict {
73         Tttype tag;
74         unkId Xgunidict_clas;
75         ttype Xgunidict_ty;
76 };
77
78 struct Sunityvartemplate {
79         Tttype tag;
80         unkId Xgunityvartemplate;
81 };
82
83 struct Suniforall {
84         Tttype tag;
85         list Xguniforall_tv;
86         ttype Xguniforall_ty;
87 };
88
89 struct Sty_maybe_nothing {
90         Tttype tag;
91 };
92
93 struct Sty_maybe_just {
94         Tttype tag;
95         ttype Xgty_maybe;
96 };
97
98 extern ttype mktname PROTO((unkId, list));
99 #ifdef __GNUC__
100
101 extern __inline__ unkId *Rgtypeid(struct Stname *t)
102 {
103 #ifdef UGEN_DEBUG
104         if(t -> tag != tname)
105                 fprintf(stderr,"gtypeid: illegal selection; was %d\n", t -> tag);
106 #endif /* UGEN_DEBUG */
107         return(& t -> Xgtypeid);
108 }
109 #else  /* ! __GNUC__ */
110 extern unkId *Rgtypeid PROTO((struct Stname *));
111 #endif /* ! __GNUC__ */
112
113 #define gtypeid(xyzxyz) (*Rgtypeid((struct Stname *) (xyzxyz)))
114 #ifdef __GNUC__
115
116 extern __inline__ list *Rgtypel(struct Stname *t)
117 {
118 #ifdef UGEN_DEBUG
119         if(t -> tag != tname)
120                 fprintf(stderr,"gtypel: illegal selection; was %d\n", t -> tag);
121 #endif /* UGEN_DEBUG */
122         return(& t -> Xgtypel);
123 }
124 #else  /* ! __GNUC__ */
125 extern list *Rgtypel PROTO((struct Stname *));
126 #endif /* ! __GNUC__ */
127
128 #define gtypel(xyzxyz) (*Rgtypel((struct Stname *) (xyzxyz)))
129
130 extern ttype mknamedtvar PROTO((unkId));
131 #ifdef __GNUC__
132
133 extern __inline__ unkId *Rgnamedtvar(struct Snamedtvar *t)
134 {
135 #ifdef UGEN_DEBUG
136         if(t -> tag != namedtvar)
137                 fprintf(stderr,"gnamedtvar: illegal selection; was %d\n", t -> tag);
138 #endif /* UGEN_DEBUG */
139         return(& t -> Xgnamedtvar);
140 }
141 #else  /* ! __GNUC__ */
142 extern unkId *Rgnamedtvar PROTO((struct Snamedtvar *));
143 #endif /* ! __GNUC__ */
144
145 #define gnamedtvar(xyzxyz) (*Rgnamedtvar((struct Snamedtvar *) (xyzxyz)))
146
147 extern ttype mktllist PROTO((ttype));
148 #ifdef __GNUC__
149
150 extern __inline__ ttype *Rgtlist(struct Stllist *t)
151 {
152 #ifdef UGEN_DEBUG
153         if(t -> tag != tllist)
154                 fprintf(stderr,"gtlist: illegal selection; was %d\n", t -> tag);
155 #endif /* UGEN_DEBUG */
156         return(& t -> Xgtlist);
157 }
158 #else  /* ! __GNUC__ */
159 extern ttype *Rgtlist PROTO((struct Stllist *));
160 #endif /* ! __GNUC__ */
161
162 #define gtlist(xyzxyz) (*Rgtlist((struct Stllist *) (xyzxyz)))
163
164 extern ttype mkttuple PROTO((list));
165 #ifdef __GNUC__
166
167 extern __inline__ list *Rgttuple(struct Sttuple *t)
168 {
169 #ifdef UGEN_DEBUG
170         if(t -> tag != ttuple)
171                 fprintf(stderr,"gttuple: illegal selection; was %d\n", t -> tag);
172 #endif /* UGEN_DEBUG */
173         return(& t -> Xgttuple);
174 }
175 #else  /* ! __GNUC__ */
176 extern list *Rgttuple PROTO((struct Sttuple *));
177 #endif /* ! __GNUC__ */
178
179 #define gttuple(xyzxyz) (*Rgttuple((struct Sttuple *) (xyzxyz)))
180
181 extern ttype mktfun PROTO((ttype, ttype));
182 #ifdef __GNUC__
183
184 extern __inline__ ttype *Rgtfun(struct Stfun *t)
185 {
186 #ifdef UGEN_DEBUG
187         if(t -> tag != tfun)
188                 fprintf(stderr,"gtfun: illegal selection; was %d\n", t -> tag);
189 #endif /* UGEN_DEBUG */
190         return(& t -> Xgtfun);
191 }
192 #else  /* ! __GNUC__ */
193 extern ttype *Rgtfun PROTO((struct Stfun *));
194 #endif /* ! __GNUC__ */
195
196 #define gtfun(xyzxyz) (*Rgtfun((struct Stfun *) (xyzxyz)))
197 #ifdef __GNUC__
198
199 extern __inline__ ttype *Rgtarg(struct Stfun *t)
200 {
201 #ifdef UGEN_DEBUG
202         if(t -> tag != tfun)
203                 fprintf(stderr,"gtarg: illegal selection; was %d\n", t -> tag);
204 #endif /* UGEN_DEBUG */
205         return(& t -> Xgtarg);
206 }
207 #else  /* ! __GNUC__ */
208 extern ttype *Rgtarg PROTO((struct Stfun *));
209 #endif /* ! __GNUC__ */
210
211 #define gtarg(xyzxyz) (*Rgtarg((struct Stfun *) (xyzxyz)))
212
213 extern ttype mkcontext PROTO((list, ttype));
214 #ifdef __GNUC__
215
216 extern __inline__ list *Rgtcontextl(struct Scontext *t)
217 {
218 #ifdef UGEN_DEBUG
219         if(t -> tag != context)
220                 fprintf(stderr,"gtcontextl: illegal selection; was %d\n", t -> tag);
221 #endif /* UGEN_DEBUG */
222         return(& t -> Xgtcontextl);
223 }
224 #else  /* ! __GNUC__ */
225 extern list *Rgtcontextl PROTO((struct Scontext *));
226 #endif /* ! __GNUC__ */
227
228 #define gtcontextl(xyzxyz) (*Rgtcontextl((struct Scontext *) (xyzxyz)))
229 #ifdef __GNUC__
230
231 extern __inline__ ttype *Rgtcontextt(struct Scontext *t)
232 {
233 #ifdef UGEN_DEBUG
234         if(t -> tag != context)
235                 fprintf(stderr,"gtcontextt: illegal selection; was %d\n", t -> tag);
236 #endif /* UGEN_DEBUG */
237         return(& t -> Xgtcontextt);
238 }
239 #else  /* ! __GNUC__ */
240 extern ttype *Rgtcontextt PROTO((struct Scontext *));
241 #endif /* ! __GNUC__ */
242
243 #define gtcontextt(xyzxyz) (*Rgtcontextt((struct Scontext *) (xyzxyz)))
244
245 extern ttype mkunidict PROTO((unkId, ttype));
246 #ifdef __GNUC__
247
248 extern __inline__ unkId *Rgunidict_clas(struct Sunidict *t)
249 {
250 #ifdef UGEN_DEBUG
251         if(t -> tag != unidict)
252                 fprintf(stderr,"gunidict_clas: illegal selection; was %d\n", t -> tag);
253 #endif /* UGEN_DEBUG */
254         return(& t -> Xgunidict_clas);
255 }
256 #else  /* ! __GNUC__ */
257 extern unkId *Rgunidict_clas PROTO((struct Sunidict *));
258 #endif /* ! __GNUC__ */
259
260 #define gunidict_clas(xyzxyz) (*Rgunidict_clas((struct Sunidict *) (xyzxyz)))
261 #ifdef __GNUC__
262
263 extern __inline__ ttype *Rgunidict_ty(struct Sunidict *t)
264 {
265 #ifdef UGEN_DEBUG
266         if(t -> tag != unidict)
267                 fprintf(stderr,"gunidict_ty: illegal selection; was %d\n", t -> tag);
268 #endif /* UGEN_DEBUG */
269         return(& t -> Xgunidict_ty);
270 }
271 #else  /* ! __GNUC__ */
272 extern ttype *Rgunidict_ty PROTO((struct Sunidict *));
273 #endif /* ! __GNUC__ */
274
275 #define gunidict_ty(xyzxyz) (*Rgunidict_ty((struct Sunidict *) (xyzxyz)))
276
277 extern ttype mkunityvartemplate PROTO((unkId));
278 #ifdef __GNUC__
279
280 extern __inline__ unkId *Rgunityvartemplate(struct Sunityvartemplate *t)
281 {
282 #ifdef UGEN_DEBUG
283         if(t -> tag != unityvartemplate)
284                 fprintf(stderr,"gunityvartemplate: illegal selection; was %d\n", t -> tag);
285 #endif /* UGEN_DEBUG */
286         return(& t -> Xgunityvartemplate);
287 }
288 #else  /* ! __GNUC__ */
289 extern unkId *Rgunityvartemplate PROTO((struct Sunityvartemplate *));
290 #endif /* ! __GNUC__ */
291
292 #define gunityvartemplate(xyzxyz) (*Rgunityvartemplate((struct Sunityvartemplate *) (xyzxyz)))
293
294 extern ttype mkuniforall PROTO((list, ttype));
295 #ifdef __GNUC__
296
297 extern __inline__ list *Rguniforall_tv(struct Suniforall *t)
298 {
299 #ifdef UGEN_DEBUG
300         if(t -> tag != uniforall)
301                 fprintf(stderr,"guniforall_tv: illegal selection; was %d\n", t -> tag);
302 #endif /* UGEN_DEBUG */
303         return(& t -> Xguniforall_tv);
304 }
305 #else  /* ! __GNUC__ */
306 extern list *Rguniforall_tv PROTO((struct Suniforall *));
307 #endif /* ! __GNUC__ */
308
309 #define guniforall_tv(xyzxyz) (*Rguniforall_tv((struct Suniforall *) (xyzxyz)))
310 #ifdef __GNUC__
311
312 extern __inline__ ttype *Rguniforall_ty(struct Suniforall *t)
313 {
314 #ifdef UGEN_DEBUG
315         if(t -> tag != uniforall)
316                 fprintf(stderr,"guniforall_ty: illegal selection; was %d\n", t -> tag);
317 #endif /* UGEN_DEBUG */
318         return(& t -> Xguniforall_ty);
319 }
320 #else  /* ! __GNUC__ */
321 extern ttype *Rguniforall_ty PROTO((struct Suniforall *));
322 #endif /* ! __GNUC__ */
323
324 #define guniforall_ty(xyzxyz) (*Rguniforall_ty((struct Suniforall *) (xyzxyz)))
325
326 extern ttype mkty_maybe_nothing PROTO(());
327
328 extern ttype mkty_maybe_just PROTO((ttype));
329 #ifdef __GNUC__
330
331 extern __inline__ ttype *Rgty_maybe(struct Sty_maybe_just *t)
332 {
333 #ifdef UGEN_DEBUG
334         if(t -> tag != ty_maybe_just)
335                 fprintf(stderr,"gty_maybe: illegal selection; was %d\n", t -> tag);
336 #endif /* UGEN_DEBUG */
337         return(& t -> Xgty_maybe);
338 }
339 #else  /* ! __GNUC__ */
340 extern ttype *Rgty_maybe PROTO((struct Sty_maybe_just *));
341 #endif /* ! __GNUC__ */
342
343 #define gty_maybe(xyzxyz) (*Rgty_maybe((struct Sty_maybe_just *) (xyzxyz)))
344
345 #endif