[project @ 1996-03-22 09:24:22 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 Tlist tlist(list t);
23 extern __inline__ Tlist tlist(list t)
24 {
25         return(t -> tag);
26 }
27 #else  /* ! __GNUC__ */
28 extern Tlist tlist PROTO((list));
29 #endif /* ! __GNUC__ */
30
31 struct Slcons {
32         Tlist tag;
33         VOID_STAR Xlhd;
34         list Xltl;
35 };
36
37 struct Slnil {
38         Tlist tag;
39 };
40
41 extern list mklcons PROTO((VOID_STAR, list));
42 #ifdef __GNUC__
43
44 VOID_STAR *Rlhd PROTO((struct Slcons *));
45
46 extern __inline__ VOID_STAR *Rlhd(struct Slcons *t)
47 {
48 #ifdef UGEN_DEBUG
49         if(t -> tag != lcons)
50                 fprintf(stderr,"lhd: illegal selection; was %d\n", t -> tag);
51 #endif /* UGEN_DEBUG */
52         return(& t -> Xlhd);
53 }
54 #else  /* ! __GNUC__ */
55 extern VOID_STAR *Rlhd PROTO((struct Slcons *));
56 #endif /* ! __GNUC__ */
57
58 #define lhd(xyzxyz) (*Rlhd((struct Slcons *) (xyzxyz)))
59 #ifdef __GNUC__
60
61 list *Rltl PROTO((struct Slcons *));
62
63 extern __inline__ list *Rltl(struct Slcons *t)
64 {
65 #ifdef UGEN_DEBUG
66         if(t -> tag != lcons)
67                 fprintf(stderr,"ltl: illegal selection; was %d\n", t -> tag);
68 #endif /* UGEN_DEBUG */
69         return(& t -> Xltl);
70 }
71 #else  /* ! __GNUC__ */
72 extern list *Rltl PROTO((struct Slcons *));
73 #endif /* ! __GNUC__ */
74
75 #define ltl(xyzxyz) (*Rltl((struct Slcons *) (xyzxyz)))
76
77 extern list mklnil PROTO((void));
78
79 #endif