]>
Commit | Line | Data |
---|---|---|
878ddf1f | 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-2000\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 | |
38 | PCCTS_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 | |
54 | class DllExportPCCTS ASTBase {\r | |
55 | #else\r | |
56 | class DllExportPCCTS ASTBase : public PCCTS_AST {\r | |
57 | #endif\r | |
58 | \r | |
59 | protected:\r | |
60 | ASTBase *_right, *_down;\r | |
61 | \r | |
62 | public:\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(void* pData = NULL /* MR23 */);\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(void* /*pData*/ = NULL /* MR23 */) { ; }\r | |
87 | virtual void preorder_before_action(void* /*pData*/ = NULL /* MR23 */) { /* MR23 */ printMessage(stdout, " ("); }\r | |
88 | virtual void preorder_after_action(void* /*pData*/ = NULL /* MR23 */) { /* MR23 */ printMessage(stdout, " )"); }\r | |
89 | virtual void panic(const char *msg); /* MR21 */\r | |
90 | virtual void reportOverwriteOfDownPointer(); /* MR21 */\r | |
91 | #ifdef PCCTS_NOT_USING_SOR\r | |
92 | virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23\r | |
93 | #endif\r | |
94 | };\r | |
95 | \r | |
96 | class DllExportPCCTS ASTDoublyLinkedBase : public ASTBase {\r | |
97 | protected:\r | |
98 | ASTDoublyLinkedBase *_left, *_up;\r | |
99 | \r | |
100 | public:\r | |
101 | void double_link(ASTBase *left, ASTBase *up);\r | |
102 | \r | |
103 | #ifndef PCCTS_NOT_USING_SOR\r | |
104 | virtual ASTBase *dup();\r | |
105 | #endif\r | |
106 | \r | |
107 | #ifdef PCCTS_NOT_USING_SOR\r | |
108 | ASTBase *left() { return _left; }\r | |
109 | ASTBase *up() { return _up; }\r | |
110 | void setLeft(ASTBase *t) { _left = (ASTDoublyLinkedBase *)t; } // MR6\r | |
111 | void setUp(ASTBase *t) { _up = (ASTDoublyLinkedBase *)t; } // MR6\r | |
112 | #else\r | |
113 | PCCTS_AST *left() { return _left; }\r | |
114 | PCCTS_AST *up() { return _up; }\r | |
115 | void setLeft(PCCTS_AST *t) { _left = (ASTDoublyLinkedBase *)t; } // MR6\r | |
116 | void setUp(PCCTS_AST *t) { _up = (ASTDoublyLinkedBase *)t; } // MR6\r | |
117 | #endif\r | |
118 | \r | |
119 | };\r | |
120 | \r | |
121 | class AST; // announce that this class will be coming along shortly\r | |
122 | #endif\r |