]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ast.h
Add in the 1st version of ECP.
[mirror_edk2.git] / EdkCompatibilityPkg / Other / Maintained / Tools / Pccts / h / ast.h
1 /* Abstract syntax tree
2 *
3 * Macros, definitions
4 *
5 * SOFTWARE RIGHTS
6 *
7 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
8 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
9 * company may do whatever they wish with source code distributed with
10 * PCCTS or the code generated by PCCTS, including the incorporation of
11 * PCCTS, or its output, into commerical software.
12 *
13 * We encourage users to develop software with PCCTS. However, we do ask
14 * that credit is given to us for developing PCCTS. By "credit",
15 * we mean that if you incorporate our source code into one of your
16 * programs (commercial product, research project, or otherwise) that you
17 * acknowledge this fact somewhere in the documentation, research report,
18 * etc... If you like PCCTS and have developed a nice tool with the
19 * output, please mention that you developed it using PCCTS. In
20 * addition, we ask that this header remain intact in our source code.
21 * As long as these guidelines are kept, we expect to continue enhancing
22 * this system and expect to make other tools available as they are
23 * completed.
24 *
25 * ANTLR 1.33
26 * Terence Parr
27 * Parr Research Corporation
28 * with Purdue University and AHPCRC, University of Minnesota
29 * 1989-1998
30 */
31
32 #ifndef ZZAST_H
33 #define ZZAST_H
34
35 #define zzastOvfChk \
36 if ( zzast_sp <= 0 ) \
37 { \
38 fprintf(stderr, zzStackOvfMsg, __FILE__, __LINE__); \
39 exit(PCCTS_EXIT_FAILURE); \
40 }
41
42 #ifndef USER_DEFINED_AST
43 #ifndef AST_FIELDS
44 #define AST_FIELDS
45 #endif
46
47 typedef struct _ast {
48 struct _ast *right, *down;
49 #ifdef zzAST_DOUBLE
50 struct _ast *left, *up;
51 #endif
52 AST_FIELDS
53 } AST;
54
55 #else
56
57 #ifdef zzAST_DOUBLE
58 #define AST_REQUIRED_FIELDS struct _ast *right, *down, *left, *up;
59 #else
60 #define AST_REQUIRED_FIELDS struct _ast *right, *down;
61 #endif
62
63 #endif
64
65
66 /* N o d e a c c e s s m a c r o s */
67 #define zzchild(t) (((t)==NULL)? (AST *) NULL:(t->down)) /* MR19 */
68 #define zzsibling(t) (((t)==NULL)? (AST *) NULL:(t->right)) /* MR19 */
69
70
71 /* define global variables needed by #i stack */
72 #define zzASTgvars \
73 AST *zzastStack[ZZAST_STACKSIZE]; \
74 int zzast_sp = ZZAST_STACKSIZE;
75
76 #define zzASTVars AST *_ast = NULL, *_sibling = NULL, *_tail = NULL
77 #define zzSTR ( (_tail==NULL)?(&_sibling):(&(_tail->right)) )
78 #define zzastCur (zzastStack[zzast_sp])
79 #define zzastArg(i) (zzastStack[zztsp-i])
80 #define zzastPush(p) zzastOvfChk; zzastStack[--zzast_sp] = p;
81 #define zzastDPush --zzast_sp
82 #define zzastMARK zztsp=zzast_sp; /* Save state of stack */
83 #define zzastREL zzast_sp=zztsp; /* Return state of stack */
84 #define zzrm_ast {zzfree_ast(*_root); _tail = _sibling = (*_root)=NULL;}
85
86 extern int zzast_sp;
87 extern AST *zzastStack[];
88
89 #ifdef __USE_PROTOS
90 void zzlink(AST **, AST **, AST **);
91 void zzsubchild(AST **, AST **, AST **);
92 void zzsubroot(AST **, AST **, AST **);
93 void zzpre_ast(AST *, void (*)(AST *), void (*)(AST *), void (*)(AST *));
94 void zzfree_ast(AST *);
95 AST *zztmake(AST *, ...);
96 AST *zzdup_ast(AST *);
97 void zztfree(AST *);
98 void zzdouble_link(AST *, AST *, AST *);
99 AST *zzastnew(void);
100
101 #else
102
103 void zzlink();
104 AST *zzastnew();
105 void zzsubchild();
106 void zzsubroot();
107 void zzpre_ast();
108 void zzfree_ast();
109 AST *zztmake();
110 AST *zzdup_ast();
111 void zztfree();
112 void zzdouble_link();
113 #endif
114
115 #endif