[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / compiler / yaccParser / list.h
1 #ifndef list_defined
2 #define list_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         lcons,
16         lnil
17 } Tlist;
18
19 typedef struct { Tlist tag; } *list;
20
21 #ifdef __GNUC__
22 extern __inline__ Tlist tlist(list t)
23 {
24         return(t -> tag);
25 }
26 #else  /* ! __GNUC__ */
27 extern Tlist tlist PROTO((list));
28 #endif /* ! __GNUC__ */
29
30 struct Slcons {
31         Tlist tag;
32         VOID_STAR Xlhd;
33         list Xltl;
34 };
35
36 struct Slnil {
37         Tlist tag;
38 };
39
40 extern list mklcons PROTO((VOID_STAR, list));
41 #ifdef __GNUC__
42
43 extern __inline__ VOID_STAR *Rlhd(struct Slcons *t)
44 {
45 #ifdef UGEN_DEBUG
46         if(t -> tag != lcons)
47                 fprintf(stderr,"lhd: illegal selection; was %d\n", t -> tag);
48 #endif /* UGEN_DEBUG */
49         return(& t -> Xlhd);
50 }
51 #else  /* ! __GNUC__ */
52 extern VOID_STAR *Rlhd PROTO((struct Slcons *));
53 #endif /* ! __GNUC__ */
54
55 #define lhd(xyzxyz) (*Rlhd((struct Slcons *) (xyzxyz)))
56 #ifdef __GNUC__
57
58 extern __inline__ list *Rltl(struct Slcons *t)
59 {
60 #ifdef UGEN_DEBUG
61         if(t -> tag != lcons)
62                 fprintf(stderr,"ltl: illegal selection; was %d\n", t -> tag);
63 #endif /* UGEN_DEBUG */
64         return(& t -> Xltl);
65 }
66 #else  /* ! __GNUC__ */
67 extern list *Rltl PROTO((struct Slcons *));
68 #endif /* ! __GNUC__ */
69
70 #define ltl(xyzxyz) (*Rltl((struct Slcons *) (xyzxyz)))
71
72 extern list mklnil PROTO(());
73
74 #endif