]>
Commit | Line | Data |
---|---|---|
878ddf1f | 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-2000\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 | |
47 | typedef 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 | |
86 | extern int zzast_sp;\r | |
87 | extern AST *zzastStack[];\r | |
88 | \r | |
89 | /* MR26 */\r | |
90 | \r | |
91 | #ifdef PCCTS_USE_STDARG\r | |
92 | AST *zztmake(AST *, ...);\r | |
93 | #else\r | |
94 | AST *zztmake();\r | |
95 | #endif\r | |
96 | \r | |
97 | #ifdef __USE_PROTOS\r | |
98 | void zzlink(AST **, AST **, AST **);\r | |
99 | void zzsubchild(AST **, AST **, AST **);\r | |
100 | void zzsubroot(AST **, AST **, AST **);\r | |
101 | void zzpre_ast(AST *, void (*)(AST *), void (*)(AST *), void (*)(AST *));\r | |
102 | void zzfree_ast(AST *);\r | |
103 | AST *zzdup_ast(AST *);\r | |
104 | void zztfree(AST *);\r | |
105 | void zzdouble_link(AST *, AST *, AST *);\r | |
106 | AST *zzastnew(void);\r | |
107 | \r | |
108 | #else\r | |
109 | \r | |
110 | void zzlink();\r | |
111 | AST *zzastnew();\r | |
112 | void zzsubchild();\r | |
113 | void zzsubroot();\r | |
114 | void zzpre_ast();\r | |
115 | void zzfree_ast();\r | |
116 | AST *zzdup_ast();\r | |
117 | void zztfree();\r | |
118 | void zzdouble_link();\r | |
119 | #endif\r | |
120 | \r | |
121 | #endif\r |