[project @ 1996-01-09 18:43:57 by partain]
[ghc-hetmet.git] / ghc / utils / ugen / tree.h
1 #ifndef tree_defined
2 #define tree_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         typdef,
16         deflist,
17         def,
18         itemlist,
19         emitemlist,
20         item
21 } Ttree;
22
23 typedef struct { Ttree tag; } *tree;
24
25 #ifdef __GNUC__
26 Ttree ttree(tree t);
27 extern __inline__ Ttree ttree(tree t)
28 {
29         return(t -> tag);
30 }
31 #else  /* ! __GNUC__ */
32 extern Ttree ttree PROTO((tree));
33 #endif /* ! __GNUC__ */
34
35 struct Stypdef {
36         Ttree tag;
37         id Xgtid;
38         tree Xgtdeflist;
39 };
40
41 struct Sdeflist {
42         Ttree tag;
43         tree Xgdeflist;
44         tree Xgdef;
45 };
46
47 struct Sdef {
48         Ttree tag;
49         id Xgdid;
50         tree Xgditemlist;
51 };
52
53 struct Sitemlist {
54         Ttree tag;
55         tree Xgitemlist;
56         tree Xgitem;
57 };
58
59 struct Semitemlist {
60         Ttree tag;
61 };
62
63 struct Sitem {
64         Ttree tag;
65         id Xgitemfunid;
66         id Xgitemtypid;
67 };
68
69 extern tree mktypdef PROTO((id, tree));
70 #ifdef __GNUC__
71
72 id *Rgtid PROTO((struct Stypdef *));
73
74 extern __inline__ id *Rgtid(struct Stypdef *t)
75 {
76 #ifdef UGEN_DEBUG
77         if(t -> tag != typdef)
78                 fprintf(stderr,"gtid: illegal selection; was %d\n", t -> tag);
79 #endif /* UGEN_DEBUG */
80         return(& t -> Xgtid);
81 }
82 #else  /* ! __GNUC__ */
83 extern id *Rgtid PROTO((struct Stypdef *));
84 #endif /* ! __GNUC__ */
85
86 #define gtid(xyzxyz) (*Rgtid((struct Stypdef *) (xyzxyz)))
87 #ifdef __GNUC__
88
89 tree *Rgtdeflist PROTO((struct Stypdef *));
90
91 extern __inline__ tree *Rgtdeflist(struct Stypdef *t)
92 {
93 #ifdef UGEN_DEBUG
94         if(t -> tag != typdef)
95                 fprintf(stderr,"gtdeflist: illegal selection; was %d\n", t -> tag);
96 #endif /* UGEN_DEBUG */
97         return(& t -> Xgtdeflist);
98 }
99 #else  /* ! __GNUC__ */
100 extern tree *Rgtdeflist PROTO((struct Stypdef *));
101 #endif /* ! __GNUC__ */
102
103 #define gtdeflist(xyzxyz) (*Rgtdeflist((struct Stypdef *) (xyzxyz)))
104
105 extern tree mkdeflist PROTO((tree, tree));
106 #ifdef __GNUC__
107
108 tree *Rgdeflist PROTO((struct Sdeflist *));
109
110 extern __inline__ tree *Rgdeflist(struct Sdeflist *t)
111 {
112 #ifdef UGEN_DEBUG
113         if(t -> tag != deflist)
114                 fprintf(stderr,"gdeflist: illegal selection; was %d\n", t -> tag);
115 #endif /* UGEN_DEBUG */
116         return(& t -> Xgdeflist);
117 }
118 #else  /* ! __GNUC__ */
119 extern tree *Rgdeflist PROTO((struct Sdeflist *));
120 #endif /* ! __GNUC__ */
121
122 #define gdeflist(xyzxyz) (*Rgdeflist((struct Sdeflist *) (xyzxyz)))
123 #ifdef __GNUC__
124
125 tree *Rgdef PROTO((struct Sdeflist *));
126
127 extern __inline__ tree *Rgdef(struct Sdeflist *t)
128 {
129 #ifdef UGEN_DEBUG
130         if(t -> tag != deflist)
131                 fprintf(stderr,"gdef: illegal selection; was %d\n", t -> tag);
132 #endif /* UGEN_DEBUG */
133         return(& t -> Xgdef);
134 }
135 #else  /* ! __GNUC__ */
136 extern tree *Rgdef PROTO((struct Sdeflist *));
137 #endif /* ! __GNUC__ */
138
139 #define gdef(xyzxyz) (*Rgdef((struct Sdeflist *) (xyzxyz)))
140
141 extern tree mkdef PROTO((id, tree));
142 #ifdef __GNUC__
143
144 id *Rgdid PROTO((struct Sdef *));
145
146 extern __inline__ id *Rgdid(struct Sdef *t)
147 {
148 #ifdef UGEN_DEBUG
149         if(t -> tag != def)
150                 fprintf(stderr,"gdid: illegal selection; was %d\n", t -> tag);
151 #endif /* UGEN_DEBUG */
152         return(& t -> Xgdid);
153 }
154 #else  /* ! __GNUC__ */
155 extern id *Rgdid PROTO((struct Sdef *));
156 #endif /* ! __GNUC__ */
157
158 #define gdid(xyzxyz) (*Rgdid((struct Sdef *) (xyzxyz)))
159 #ifdef __GNUC__
160
161 tree *Rgditemlist PROTO((struct Sdef *));
162
163 extern __inline__ tree *Rgditemlist(struct Sdef *t)
164 {
165 #ifdef UGEN_DEBUG
166         if(t -> tag != def)
167                 fprintf(stderr,"gditemlist: illegal selection; was %d\n", t -> tag);
168 #endif /* UGEN_DEBUG */
169         return(& t -> Xgditemlist);
170 }
171 #else  /* ! __GNUC__ */
172 extern tree *Rgditemlist PROTO((struct Sdef *));
173 #endif /* ! __GNUC__ */
174
175 #define gditemlist(xyzxyz) (*Rgditemlist((struct Sdef *) (xyzxyz)))
176
177 extern tree mkitemlist PROTO((tree, tree));
178 #ifdef __GNUC__
179
180 tree *Rgitemlist PROTO((struct Sitemlist *));
181
182 extern __inline__ tree *Rgitemlist(struct Sitemlist *t)
183 {
184 #ifdef UGEN_DEBUG
185         if(t -> tag != itemlist)
186                 fprintf(stderr,"gitemlist: illegal selection; was %d\n", t -> tag);
187 #endif /* UGEN_DEBUG */
188         return(& t -> Xgitemlist);
189 }
190 #else  /* ! __GNUC__ */
191 extern tree *Rgitemlist PROTO((struct Sitemlist *));
192 #endif /* ! __GNUC__ */
193
194 #define gitemlist(xyzxyz) (*Rgitemlist((struct Sitemlist *) (xyzxyz)))
195 #ifdef __GNUC__
196
197 tree *Rgitem PROTO((struct Sitemlist *));
198
199 extern __inline__ tree *Rgitem(struct Sitemlist *t)
200 {
201 #ifdef UGEN_DEBUG
202         if(t -> tag != itemlist)
203                 fprintf(stderr,"gitem: illegal selection; was %d\n", t -> tag);
204 #endif /* UGEN_DEBUG */
205         return(& t -> Xgitem);
206 }
207 #else  /* ! __GNUC__ */
208 extern tree *Rgitem PROTO((struct Sitemlist *));
209 #endif /* ! __GNUC__ */
210
211 #define gitem(xyzxyz) (*Rgitem((struct Sitemlist *) (xyzxyz)))
212
213 extern tree mkemitemlist PROTO((void));
214
215 extern tree mkitem PROTO((id, id));
216 #ifdef __GNUC__
217
218 id *Rgitemfunid PROTO((struct Sitem *));
219
220 extern __inline__ id *Rgitemfunid(struct Sitem *t)
221 {
222 #ifdef UGEN_DEBUG
223         if(t -> tag != item)
224                 fprintf(stderr,"gitemfunid: illegal selection; was %d\n", t -> tag);
225 #endif /* UGEN_DEBUG */
226         return(& t -> Xgitemfunid);
227 }
228 #else  /* ! __GNUC__ */
229 extern id *Rgitemfunid PROTO((struct Sitem *));
230 #endif /* ! __GNUC__ */
231
232 #define gitemfunid(xyzxyz) (*Rgitemfunid((struct Sitem *) (xyzxyz)))
233 #ifdef __GNUC__
234
235 id *Rgitemtypid PROTO((struct Sitem *));
236
237 extern __inline__ id *Rgitemtypid(struct Sitem *t)
238 {
239 #ifdef UGEN_DEBUG
240         if(t -> tag != item)
241                 fprintf(stderr,"gitemtypid: illegal selection; was %d\n", t -> tag);
242 #endif /* UGEN_DEBUG */
243         return(& t -> Xgitemtypid);
244 }
245 #else  /* ! __GNUC__ */
246 extern id *Rgitemtypid PROTO((struct Sitem *));
247 #endif /* ! __GNUC__ */
248
249 #define gitemtypid(xyzxyz) (*Rgitemtypid((struct Sitem *) (xyzxyz)))
250
251 #endif