[project @ 1996-03-22 09:24:22 by partain]
[ghc-hetmet.git] / ghc / compiler / yaccParser / literal.h
1 #ifndef literal_defined
2 #define literal_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         integer,
16         intprim,
17         floatr,
18         doubleprim,
19         floatprim,
20         charr,
21         charprim,
22         string,
23         stringprim,
24         clitlit,
25         norepi,
26         norepr,
27         noreps
28 } Tliteral;
29
30 typedef struct { Tliteral tag; } *literal;
31
32 #ifdef __GNUC__
33 Tliteral tliteral(literal t);
34 extern __inline__ Tliteral tliteral(literal t)
35 {
36         return(t -> tag);
37 }
38 #else  /* ! __GNUC__ */
39 extern Tliteral tliteral PROTO((literal));
40 #endif /* ! __GNUC__ */
41
42 struct Sinteger {
43         Tliteral tag;
44         stringId Xginteger;
45 };
46
47 struct Sintprim {
48         Tliteral tag;
49         stringId Xgintprim;
50 };
51
52 struct Sfloatr {
53         Tliteral tag;
54         stringId Xgfloatr;
55 };
56
57 struct Sdoubleprim {
58         Tliteral tag;
59         stringId Xgdoubleprim;
60 };
61
62 struct Sfloatprim {
63         Tliteral tag;
64         stringId Xgfloatprim;
65 };
66
67 struct Scharr {
68         Tliteral tag;
69         hstring Xgchar;
70 };
71
72 struct Scharprim {
73         Tliteral tag;
74         hstring Xgcharprim;
75 };
76
77 struct Sstring {
78         Tliteral tag;
79         hstring Xgstring;
80 };
81
82 struct Sstringprim {
83         Tliteral tag;
84         hstring Xgstringprim;
85 };
86
87 struct Sclitlit {
88         Tliteral tag;
89         stringId Xgclitlit;
90         stringId Xgclitlit_kind;
91 };
92
93 struct Snorepi {
94         Tliteral tag;
95         stringId Xgnorepi;
96 };
97
98 struct Snorepr {
99         Tliteral tag;
100         stringId Xgnorepr_n;
101         stringId Xgnorepr_d;
102 };
103
104 struct Snoreps {
105         Tliteral tag;
106         hstring Xgnoreps;
107 };
108
109 extern literal mkinteger PROTO((stringId));
110 #ifdef __GNUC__
111
112 stringId *Rginteger PROTO((struct Sinteger *));
113
114 extern __inline__ stringId *Rginteger(struct Sinteger *t)
115 {
116 #ifdef UGEN_DEBUG
117         if(t -> tag != integer)
118                 fprintf(stderr,"ginteger: illegal selection; was %d\n", t -> tag);
119 #endif /* UGEN_DEBUG */
120         return(& t -> Xginteger);
121 }
122 #else  /* ! __GNUC__ */
123 extern stringId *Rginteger PROTO((struct Sinteger *));
124 #endif /* ! __GNUC__ */
125
126 #define ginteger(xyzxyz) (*Rginteger((struct Sinteger *) (xyzxyz)))
127
128 extern literal mkintprim PROTO((stringId));
129 #ifdef __GNUC__
130
131 stringId *Rgintprim PROTO((struct Sintprim *));
132
133 extern __inline__ stringId *Rgintprim(struct Sintprim *t)
134 {
135 #ifdef UGEN_DEBUG
136         if(t -> tag != intprim)
137                 fprintf(stderr,"gintprim: illegal selection; was %d\n", t -> tag);
138 #endif /* UGEN_DEBUG */
139         return(& t -> Xgintprim);
140 }
141 #else  /* ! __GNUC__ */
142 extern stringId *Rgintprim PROTO((struct Sintprim *));
143 #endif /* ! __GNUC__ */
144
145 #define gintprim(xyzxyz) (*Rgintprim((struct Sintprim *) (xyzxyz)))
146
147 extern literal mkfloatr PROTO((stringId));
148 #ifdef __GNUC__
149
150 stringId *Rgfloatr PROTO((struct Sfloatr *));
151
152 extern __inline__ stringId *Rgfloatr(struct Sfloatr *t)
153 {
154 #ifdef UGEN_DEBUG
155         if(t -> tag != floatr)
156                 fprintf(stderr,"gfloatr: illegal selection; was %d\n", t -> tag);
157 #endif /* UGEN_DEBUG */
158         return(& t -> Xgfloatr);
159 }
160 #else  /* ! __GNUC__ */
161 extern stringId *Rgfloatr PROTO((struct Sfloatr *));
162 #endif /* ! __GNUC__ */
163
164 #define gfloatr(xyzxyz) (*Rgfloatr((struct Sfloatr *) (xyzxyz)))
165
166 extern literal mkdoubleprim PROTO((stringId));
167 #ifdef __GNUC__
168
169 stringId *Rgdoubleprim PROTO((struct Sdoubleprim *));
170
171 extern __inline__ stringId *Rgdoubleprim(struct Sdoubleprim *t)
172 {
173 #ifdef UGEN_DEBUG
174         if(t -> tag != doubleprim)
175                 fprintf(stderr,"gdoubleprim: illegal selection; was %d\n", t -> tag);
176 #endif /* UGEN_DEBUG */
177         return(& t -> Xgdoubleprim);
178 }
179 #else  /* ! __GNUC__ */
180 extern stringId *Rgdoubleprim PROTO((struct Sdoubleprim *));
181 #endif /* ! __GNUC__ */
182
183 #define gdoubleprim(xyzxyz) (*Rgdoubleprim((struct Sdoubleprim *) (xyzxyz)))
184
185 extern literal mkfloatprim PROTO((stringId));
186 #ifdef __GNUC__
187
188 stringId *Rgfloatprim PROTO((struct Sfloatprim *));
189
190 extern __inline__ stringId *Rgfloatprim(struct Sfloatprim *t)
191 {
192 #ifdef UGEN_DEBUG
193         if(t -> tag != floatprim)
194                 fprintf(stderr,"gfloatprim: illegal selection; was %d\n", t -> tag);
195 #endif /* UGEN_DEBUG */
196         return(& t -> Xgfloatprim);
197 }
198 #else  /* ! __GNUC__ */
199 extern stringId *Rgfloatprim PROTO((struct Sfloatprim *));
200 #endif /* ! __GNUC__ */
201
202 #define gfloatprim(xyzxyz) (*Rgfloatprim((struct Sfloatprim *) (xyzxyz)))
203
204 extern literal mkcharr PROTO((hstring));
205 #ifdef __GNUC__
206
207 hstring *Rgchar PROTO((struct Scharr *));
208
209 extern __inline__ hstring *Rgchar(struct Scharr *t)
210 {
211 #ifdef UGEN_DEBUG
212         if(t -> tag != charr)
213                 fprintf(stderr,"gchar: illegal selection; was %d\n", t -> tag);
214 #endif /* UGEN_DEBUG */
215         return(& t -> Xgchar);
216 }
217 #else  /* ! __GNUC__ */
218 extern hstring *Rgchar PROTO((struct Scharr *));
219 #endif /* ! __GNUC__ */
220
221 #define gchar(xyzxyz) (*Rgchar((struct Scharr *) (xyzxyz)))
222
223 extern literal mkcharprim PROTO((hstring));
224 #ifdef __GNUC__
225
226 hstring *Rgcharprim PROTO((struct Scharprim *));
227
228 extern __inline__ hstring *Rgcharprim(struct Scharprim *t)
229 {
230 #ifdef UGEN_DEBUG
231         if(t -> tag != charprim)
232                 fprintf(stderr,"gcharprim: illegal selection; was %d\n", t -> tag);
233 #endif /* UGEN_DEBUG */
234         return(& t -> Xgcharprim);
235 }
236 #else  /* ! __GNUC__ */
237 extern hstring *Rgcharprim PROTO((struct Scharprim *));
238 #endif /* ! __GNUC__ */
239
240 #define gcharprim(xyzxyz) (*Rgcharprim((struct Scharprim *) (xyzxyz)))
241
242 extern literal mkstring PROTO((hstring));
243 #ifdef __GNUC__
244
245 hstring *Rgstring PROTO((struct Sstring *));
246
247 extern __inline__ hstring *Rgstring(struct Sstring *t)
248 {
249 #ifdef UGEN_DEBUG
250         if(t -> tag != string)
251                 fprintf(stderr,"gstring: illegal selection; was %d\n", t -> tag);
252 #endif /* UGEN_DEBUG */
253         return(& t -> Xgstring);
254 }
255 #else  /* ! __GNUC__ */
256 extern hstring *Rgstring PROTO((struct Sstring *));
257 #endif /* ! __GNUC__ */
258
259 #define gstring(xyzxyz) (*Rgstring((struct Sstring *) (xyzxyz)))
260
261 extern literal mkstringprim PROTO((hstring));
262 #ifdef __GNUC__
263
264 hstring *Rgstringprim PROTO((struct Sstringprim *));
265
266 extern __inline__ hstring *Rgstringprim(struct Sstringprim *t)
267 {
268 #ifdef UGEN_DEBUG
269         if(t -> tag != stringprim)
270                 fprintf(stderr,"gstringprim: illegal selection; was %d\n", t -> tag);
271 #endif /* UGEN_DEBUG */
272         return(& t -> Xgstringprim);
273 }
274 #else  /* ! __GNUC__ */
275 extern hstring *Rgstringprim PROTO((struct Sstringprim *));
276 #endif /* ! __GNUC__ */
277
278 #define gstringprim(xyzxyz) (*Rgstringprim((struct Sstringprim *) (xyzxyz)))
279
280 extern literal mkclitlit PROTO((stringId, stringId));
281 #ifdef __GNUC__
282
283 stringId *Rgclitlit PROTO((struct Sclitlit *));
284
285 extern __inline__ stringId *Rgclitlit(struct Sclitlit *t)
286 {
287 #ifdef UGEN_DEBUG
288         if(t -> tag != clitlit)
289                 fprintf(stderr,"gclitlit: illegal selection; was %d\n", t -> tag);
290 #endif /* UGEN_DEBUG */
291         return(& t -> Xgclitlit);
292 }
293 #else  /* ! __GNUC__ */
294 extern stringId *Rgclitlit PROTO((struct Sclitlit *));
295 #endif /* ! __GNUC__ */
296
297 #define gclitlit(xyzxyz) (*Rgclitlit((struct Sclitlit *) (xyzxyz)))
298 #ifdef __GNUC__
299
300 stringId *Rgclitlit_kind PROTO((struct Sclitlit *));
301
302 extern __inline__ stringId *Rgclitlit_kind(struct Sclitlit *t)
303 {
304 #ifdef UGEN_DEBUG
305         if(t -> tag != clitlit)
306                 fprintf(stderr,"gclitlit_kind: illegal selection; was %d\n", t -> tag);
307 #endif /* UGEN_DEBUG */
308         return(& t -> Xgclitlit_kind);
309 }
310 #else  /* ! __GNUC__ */
311 extern stringId *Rgclitlit_kind PROTO((struct Sclitlit *));
312 #endif /* ! __GNUC__ */
313
314 #define gclitlit_kind(xyzxyz) (*Rgclitlit_kind((struct Sclitlit *) (xyzxyz)))
315
316 extern literal mknorepi PROTO((stringId));
317 #ifdef __GNUC__
318
319 stringId *Rgnorepi PROTO((struct Snorepi *));
320
321 extern __inline__ stringId *Rgnorepi(struct Snorepi *t)
322 {
323 #ifdef UGEN_DEBUG
324         if(t -> tag != norepi)
325                 fprintf(stderr,"gnorepi: illegal selection; was %d\n", t -> tag);
326 #endif /* UGEN_DEBUG */
327         return(& t -> Xgnorepi);
328 }
329 #else  /* ! __GNUC__ */
330 extern stringId *Rgnorepi PROTO((struct Snorepi *));
331 #endif /* ! __GNUC__ */
332
333 #define gnorepi(xyzxyz) (*Rgnorepi((struct Snorepi *) (xyzxyz)))
334
335 extern literal mknorepr PROTO((stringId, stringId));
336 #ifdef __GNUC__
337
338 stringId *Rgnorepr_n PROTO((struct Snorepr *));
339
340 extern __inline__ stringId *Rgnorepr_n(struct Snorepr *t)
341 {
342 #ifdef UGEN_DEBUG
343         if(t -> tag != norepr)
344                 fprintf(stderr,"gnorepr_n: illegal selection; was %d\n", t -> tag);
345 #endif /* UGEN_DEBUG */
346         return(& t -> Xgnorepr_n);
347 }
348 #else  /* ! __GNUC__ */
349 extern stringId *Rgnorepr_n PROTO((struct Snorepr *));
350 #endif /* ! __GNUC__ */
351
352 #define gnorepr_n(xyzxyz) (*Rgnorepr_n((struct Snorepr *) (xyzxyz)))
353 #ifdef __GNUC__
354
355 stringId *Rgnorepr_d PROTO((struct Snorepr *));
356
357 extern __inline__ stringId *Rgnorepr_d(struct Snorepr *t)
358 {
359 #ifdef UGEN_DEBUG
360         if(t -> tag != norepr)
361                 fprintf(stderr,"gnorepr_d: illegal selection; was %d\n", t -> tag);
362 #endif /* UGEN_DEBUG */
363         return(& t -> Xgnorepr_d);
364 }
365 #else  /* ! __GNUC__ */
366 extern stringId *Rgnorepr_d PROTO((struct Snorepr *));
367 #endif /* ! __GNUC__ */
368
369 #define gnorepr_d(xyzxyz) (*Rgnorepr_d((struct Snorepr *) (xyzxyz)))
370
371 extern literal mknoreps PROTO((hstring));
372 #ifdef __GNUC__
373
374 hstring *Rgnoreps PROTO((struct Snoreps *));
375
376 extern __inline__ hstring *Rgnoreps(struct Snoreps *t)
377 {
378 #ifdef UGEN_DEBUG
379         if(t -> tag != noreps)
380                 fprintf(stderr,"gnoreps: illegal selection; was %d\n", t -> tag);
381 #endif /* UGEN_DEBUG */
382         return(& t -> Xgnoreps);
383 }
384 #else  /* ! __GNUC__ */
385 extern hstring *Rgnoreps PROTO((struct Snoreps *));
386 #endif /* ! __GNUC__ */
387
388 #define gnoreps(xyzxyz) (*Rgnoreps((struct Snoreps *) (xyzxyz)))
389
390 #endif