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