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