]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ASTBase.h
Add in the 1st version of ECP.
[mirror_edk2.git] / EdkCompatibilityPkg / Other / Maintained / Tools / Pccts / h / ASTBase.h
CommitLineData
3eb9473e 1/* Abstract syntax tree\r
2 *\r
3 * SOFTWARE RIGHTS\r
4 *\r
5 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
6 * Set (PCCTS) -- PCCTS is in the public domain. An individual or\r
7 * company may do whatever they wish with source code distributed with\r
8 * PCCTS or the code generated by PCCTS, including the incorporation of\r
9 * PCCTS, or its output, into commerical software.\r
10 *\r
11 * We encourage users to develop software with PCCTS. However, we do ask\r
12 * that credit is given to us for developing PCCTS. By "credit",\r
13 * we mean that if you incorporate our source code into one of your\r
14 * programs (commercial product, research project, or otherwise) that you\r
15 * acknowledge this fact somewhere in the documentation, research report,\r
16 * etc... If you like PCCTS and have developed a nice tool with the\r
17 * output, please mention that you developed it using PCCTS. In\r
18 * addition, we ask that this header remain intact in our source code.\r
19 * As long as these guidelines are kept, we expect to continue enhancing\r
20 * this system and expect to make other tools available as they are\r
21 * completed.\r
22 *\r
23 * ANTLR 1.33\r
24 * Terence Parr\r
25 * Parr Research Corporation\r
26 * with Purdue University and AHPCRC, University of Minnesota\r
27 * 1989-1998\r
28 */\r
29\r
30#ifndef ASTBase_H\r
31#define ASTBase_H\r
32\r
33#include "pcctscfg.h"\r
34\r
35#include "pccts_stdio.h"\r
36#include "pccts_stdlib.h"\r
37\r
38PCCTS_NAMESPACE_STD\r
39\r
40#ifndef PCCTS_NOT_USING_SOR\r
41#include "PCCTSAST.h"\r
42#endif\r
43\r
44/*\r
45 * Notes:\r
46 *\r
47 * To specify a copy constructor, subclass one of these classes and\r
48 * give the copy constructor. To use dup(), you must define shallowCopy().\r
49 * shallowCopy() can use either a copy constructor or just copy the node\r
50 * itself.\r
51 */\r
52\r
53#ifdef PCCTS_NOT_USING_SOR\r
54class DllExportPCCTS ASTBase {\r
55#else\r
56class DllExportPCCTS ASTBase : public PCCTS_AST {\r
57#endif\r
58\r
59protected:\r
60 ASTBase *_right, *_down;\r
61\r
62public:\r
63\r
64#ifdef PCCTS_NOT_USING_SOR\r
65 ASTBase *right() { return _right; }\r
66 ASTBase *down() { return _down; }\r
67 void setRight(ASTBase *t) { _right = (ASTBase *)t; }\r
68 void setDown(ASTBase *t) { _down = (ASTBase *)t; }\r
69#else\r
70 PCCTS_AST *right() { return _right; } // define the SORCERER interface\r
71 PCCTS_AST *down() { return _down; }\r
72 void setRight(PCCTS_AST *t) { _right = (ASTBase *)t; }\r
73 void setDown(PCCTS_AST *t) { _down = (ASTBase *)t; }\r
74#endif\r
75 ASTBase() { _right = _down = NULL; }\r
76 virtual ~ASTBase() { ; }\r
77#ifndef PCCTS_NOT_USING_SOR\r
78 virtual ASTBase *dup();\r
79#endif\r
80 void destroy();\r
81 void preorder();\r
82 static ASTBase *tmake(ASTBase *, ...);\r
83 static void link(ASTBase **, ASTBase **, ASTBase **);\r
84 void subchild(ASTBase **, ASTBase **, ASTBase **);\r
85 void subroot(ASTBase **, ASTBase **, ASTBase **);\r
86 virtual void preorder_action() { ; }\r
87 virtual void preorder_before_action() { printf(" ("); }\r
88 virtual void preorder_after_action() { printf(" )"); }\r
89 virtual void panic(const char *msg); /* MR21 */\r
90 virtual void reportOverwriteOfDownPointer(); /* MR21 */\r
91};\r
92\r
93class DllExportPCCTS ASTDoublyLinkedBase : public ASTBase {\r
94protected:\r
95 ASTDoublyLinkedBase *_left, *_up;\r
96\r
97public:\r
98 void double_link(ASTBase *left, ASTBase *up);\r
99\r
100#ifndef PCCTS_NOT_USING_SOR\r
101 virtual ASTBase *dup();\r
102#endif\r
103\r
104#ifdef PCCTS_NOT_USING_SOR\r
105 ASTBase *left() { return _left; }\r
106 ASTBase *up() { return _up; }\r
107 void setLeft(ASTBase *t) { _left = (ASTDoublyLinkedBase *)t; } // MR6\r
108 void setUp(ASTBase *t) { _up = (ASTDoublyLinkedBase *)t; } // MR6\r
109#else\r
110 PCCTS_AST *left() { return _left; }\r
111 PCCTS_AST *up() { return _up; }\r
112 void setLeft(PCCTS_AST *t) { _left = (ASTDoublyLinkedBase *)t; } // MR6\r
113 void setUp(PCCTS_AST *t) { _up = (ASTDoublyLinkedBase *)t; } // MR6\r
114#endif\r
115\r
116};\r
117\r
118class AST; // announce that this class will be coming along shortly\r
119#endif\r