[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / compiler / yaccParser / literal.c
1
2
3 #include "hspincl.h"
4 #include "yaccParser/literal.h"
5
6 Tliteral tliteral(t)
7  literal t;
8 {
9         return(t -> tag);
10 }
11
12
13 /************** integer ******************/
14
15 literal mkinteger(PPginteger)
16  stringId PPginteger;
17 {
18         register struct Sinteger *pp =
19                 (struct Sinteger *) malloc(sizeof(struct Sinteger));
20         pp -> tag = integer;
21         pp -> Xginteger = PPginteger;
22         return((literal)pp);
23 }
24
25 stringId *Rginteger(t)
26  struct Sinteger *t;
27 {
28 #ifdef UGEN_DEBUG
29         if(t -> tag != integer)
30                 fprintf(stderr,"ginteger: illegal selection; was %d\n", t -> tag);
31 #endif /* UGEN_DEBUG */
32         return(& t -> Xginteger);
33 }
34
35 /************** intprim ******************/
36
37 literal mkintprim(PPgintprim)
38  stringId PPgintprim;
39 {
40         register struct Sintprim *pp =
41                 (struct Sintprim *) malloc(sizeof(struct Sintprim));
42         pp -> tag = intprim;
43         pp -> Xgintprim = PPgintprim;
44         return((literal)pp);
45 }
46
47 stringId *Rgintprim(t)
48  struct Sintprim *t;
49 {
50 #ifdef UGEN_DEBUG
51         if(t -> tag != intprim)
52                 fprintf(stderr,"gintprim: illegal selection; was %d\n", t -> tag);
53 #endif /* UGEN_DEBUG */
54         return(& t -> Xgintprim);
55 }
56
57 /************** floatr ******************/
58
59 literal mkfloatr(PPgfloatr)
60  stringId PPgfloatr;
61 {
62         register struct Sfloatr *pp =
63                 (struct Sfloatr *) malloc(sizeof(struct Sfloatr));
64         pp -> tag = floatr;
65         pp -> Xgfloatr = PPgfloatr;
66         return((literal)pp);
67 }
68
69 stringId *Rgfloatr(t)
70  struct Sfloatr *t;
71 {
72 #ifdef UGEN_DEBUG
73         if(t -> tag != floatr)
74                 fprintf(stderr,"gfloatr: illegal selection; was %d\n", t -> tag);
75 #endif /* UGEN_DEBUG */
76         return(& t -> Xgfloatr);
77 }
78
79 /************** doubleprim ******************/
80
81 literal mkdoubleprim(PPgdoubleprim)
82  stringId PPgdoubleprim;
83 {
84         register struct Sdoubleprim *pp =
85                 (struct Sdoubleprim *) malloc(sizeof(struct Sdoubleprim));
86         pp -> tag = doubleprim;
87         pp -> Xgdoubleprim = PPgdoubleprim;
88         return((literal)pp);
89 }
90
91 stringId *Rgdoubleprim(t)
92  struct Sdoubleprim *t;
93 {
94 #ifdef UGEN_DEBUG
95         if(t -> tag != doubleprim)
96                 fprintf(stderr,"gdoubleprim: illegal selection; was %d\n", t -> tag);
97 #endif /* UGEN_DEBUG */
98         return(& t -> Xgdoubleprim);
99 }
100
101 /************** floatprim ******************/
102
103 literal mkfloatprim(PPgfloatprim)
104  stringId PPgfloatprim;
105 {
106         register struct Sfloatprim *pp =
107                 (struct Sfloatprim *) malloc(sizeof(struct Sfloatprim));
108         pp -> tag = floatprim;
109         pp -> Xgfloatprim = PPgfloatprim;
110         return((literal)pp);
111 }
112
113 stringId *Rgfloatprim(t)
114  struct Sfloatprim *t;
115 {
116 #ifdef UGEN_DEBUG
117         if(t -> tag != floatprim)
118                 fprintf(stderr,"gfloatprim: illegal selection; was %d\n", t -> tag);
119 #endif /* UGEN_DEBUG */
120         return(& t -> Xgfloatprim);
121 }
122
123 /************** charr ******************/
124
125 literal mkcharr(PPgchar)
126  hstring PPgchar;
127 {
128         register struct Scharr *pp =
129                 (struct Scharr *) malloc(sizeof(struct Scharr));
130         pp -> tag = charr;
131         pp -> Xgchar = PPgchar;
132         return((literal)pp);
133 }
134
135 hstring *Rgchar(t)
136  struct Scharr *t;
137 {
138 #ifdef UGEN_DEBUG
139         if(t -> tag != charr)
140                 fprintf(stderr,"gchar: illegal selection; was %d\n", t -> tag);
141 #endif /* UGEN_DEBUG */
142         return(& t -> Xgchar);
143 }
144
145 /************** charprim ******************/
146
147 literal mkcharprim(PPgcharprim)
148  hstring PPgcharprim;
149 {
150         register struct Scharprim *pp =
151                 (struct Scharprim *) malloc(sizeof(struct Scharprim));
152         pp -> tag = charprim;
153         pp -> Xgcharprim = PPgcharprim;
154         return((literal)pp);
155 }
156
157 hstring *Rgcharprim(t)
158  struct Scharprim *t;
159 {
160 #ifdef UGEN_DEBUG
161         if(t -> tag != charprim)
162                 fprintf(stderr,"gcharprim: illegal selection; was %d\n", t -> tag);
163 #endif /* UGEN_DEBUG */
164         return(& t -> Xgcharprim);
165 }
166
167 /************** string ******************/
168
169 literal mkstring(PPgstring)
170  hstring PPgstring;
171 {
172         register struct Sstring *pp =
173                 (struct Sstring *) malloc(sizeof(struct Sstring));
174         pp -> tag = string;
175         pp -> Xgstring = PPgstring;
176         return((literal)pp);
177 }
178
179 hstring *Rgstring(t)
180  struct Sstring *t;
181 {
182 #ifdef UGEN_DEBUG
183         if(t -> tag != string)
184                 fprintf(stderr,"gstring: illegal selection; was %d\n", t -> tag);
185 #endif /* UGEN_DEBUG */
186         return(& t -> Xgstring);
187 }
188
189 /************** stringprim ******************/
190
191 literal mkstringprim(PPgstringprim)
192  hstring PPgstringprim;
193 {
194         register struct Sstringprim *pp =
195                 (struct Sstringprim *) malloc(sizeof(struct Sstringprim));
196         pp -> tag = stringprim;
197         pp -> Xgstringprim = PPgstringprim;
198         return((literal)pp);
199 }
200
201 hstring *Rgstringprim(t)
202  struct Sstringprim *t;
203 {
204 #ifdef UGEN_DEBUG
205         if(t -> tag != stringprim)
206                 fprintf(stderr,"gstringprim: illegal selection; was %d\n", t -> tag);
207 #endif /* UGEN_DEBUG */
208         return(& t -> Xgstringprim);
209 }
210
211 /************** clitlit ******************/
212
213 literal mkclitlit(PPgclitlit, PPgclitlit_kind)
214  stringId PPgclitlit;
215  stringId PPgclitlit_kind;
216 {
217         register struct Sclitlit *pp =
218                 (struct Sclitlit *) malloc(sizeof(struct Sclitlit));
219         pp -> tag = clitlit;
220         pp -> Xgclitlit = PPgclitlit;
221         pp -> Xgclitlit_kind = PPgclitlit_kind;
222         return((literal)pp);
223 }
224
225 stringId *Rgclitlit(t)
226  struct Sclitlit *t;
227 {
228 #ifdef UGEN_DEBUG
229         if(t -> tag != clitlit)
230                 fprintf(stderr,"gclitlit: illegal selection; was %d\n", t -> tag);
231 #endif /* UGEN_DEBUG */
232         return(& t -> Xgclitlit);
233 }
234
235 stringId *Rgclitlit_kind(t)
236  struct Sclitlit *t;
237 {
238 #ifdef UGEN_DEBUG
239         if(t -> tag != clitlit)
240                 fprintf(stderr,"gclitlit_kind: illegal selection; was %d\n", t -> tag);
241 #endif /* UGEN_DEBUG */
242         return(& t -> Xgclitlit_kind);
243 }
244
245 /************** norepi ******************/
246
247 literal mknorepi(PPgnorepi)
248  stringId PPgnorepi;
249 {
250         register struct Snorepi *pp =
251                 (struct Snorepi *) malloc(sizeof(struct Snorepi));
252         pp -> tag = norepi;
253         pp -> Xgnorepi = PPgnorepi;
254         return((literal)pp);
255 }
256
257 stringId *Rgnorepi(t)
258  struct Snorepi *t;
259 {
260 #ifdef UGEN_DEBUG
261         if(t -> tag != norepi)
262                 fprintf(stderr,"gnorepi: illegal selection; was %d\n", t -> tag);
263 #endif /* UGEN_DEBUG */
264         return(& t -> Xgnorepi);
265 }
266
267 /************** norepr ******************/
268
269 literal mknorepr(PPgnorepr_n, PPgnorepr_d)
270  stringId PPgnorepr_n;
271  stringId PPgnorepr_d;
272 {
273         register struct Snorepr *pp =
274                 (struct Snorepr *) malloc(sizeof(struct Snorepr));
275         pp -> tag = norepr;
276         pp -> Xgnorepr_n = PPgnorepr_n;
277         pp -> Xgnorepr_d = PPgnorepr_d;
278         return((literal)pp);
279 }
280
281 stringId *Rgnorepr_n(t)
282  struct Snorepr *t;
283 {
284 #ifdef UGEN_DEBUG
285         if(t -> tag != norepr)
286                 fprintf(stderr,"gnorepr_n: illegal selection; was %d\n", t -> tag);
287 #endif /* UGEN_DEBUG */
288         return(& t -> Xgnorepr_n);
289 }
290
291 stringId *Rgnorepr_d(t)
292  struct Snorepr *t;
293 {
294 #ifdef UGEN_DEBUG
295         if(t -> tag != norepr)
296                 fprintf(stderr,"gnorepr_d: illegal selection; was %d\n", t -> tag);
297 #endif /* UGEN_DEBUG */
298         return(& t -> Xgnorepr_d);
299 }
300
301 /************** noreps ******************/
302
303 literal mknoreps(PPgnoreps)
304  hstring PPgnoreps;
305 {
306         register struct Snoreps *pp =
307                 (struct Snoreps *) malloc(sizeof(struct Snoreps));
308         pp -> tag = noreps;
309         pp -> Xgnoreps = PPgnoreps;
310         return((literal)pp);
311 }
312
313 hstring *Rgnoreps(t)
314  struct Snoreps *t;
315 {
316 #ifdef UGEN_DEBUG
317         if(t -> tag != noreps)
318                 fprintf(stderr,"gnoreps: illegal selection; was %d\n", t -> tag);
319 #endif /* UGEN_DEBUG */
320         return(& t -> Xgnoreps);
321 }