]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/CCode/Source/Pccts/h/ASTBase.cpp
Retiring the ANT/JAVA build and removing the older EDK II packages that required...
[mirror_edk2.git] / Tools / CCode / Source / Pccts / h / ASTBase.cpp
diff --git a/Tools/CCode/Source/Pccts/h/ASTBase.cpp b/Tools/CCode/Source/Pccts/h/ASTBase.cpp
deleted file mode 100644 (file)
index a94f080..0000000
+++ /dev/null
@@ -1,256 +0,0 @@
-/* Abstract syntax tree manipulation functions\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#include "pcctscfg.h"\r
-\r
-#include "pccts_stdio.h"\r
-#include "pccts_stdarg.h"\r
-\r
-PCCTS_NAMESPACE_STD\r
-\r
-#define ANTLR_SUPPORT_CODE\r
-\r
-#include "ASTBase.h"\r
-\r
-/* ensure that tree manipulation variables are current after a rule\r
- * reference\r
- */\r
-void\r
-ASTBase::link(ASTBase **_root, ASTBase **_sibling, ASTBase **_tail)\r
-{\r
-       if ( *_sibling == NULL ) return;\r
-       if ( *_root == NULL ) *_root = *_sibling;\r
-       else if ( *_root != *_sibling ) (*_root)->_down = *_sibling;\r
-       if ( *_tail==NULL ) *_tail = *_sibling;\r
-       while ( (*_tail)->_right != NULL ) *_tail = (*_tail)->_right;\r
-}\r
-\r
-/* add a child node to the current sibling list */\r
-void\r
-ASTBase::subchild(ASTBase **_root, ASTBase **_sibling, ASTBase **_tail)\r
-{\r
-       if ( *_tail != NULL ) (*_tail)->_right = this;\r
-       else {\r
-               *_sibling = this;\r
-               if ( *_root != NULL ) (*_root)->_down = *_sibling;\r
-       }\r
-       *_tail = this;\r
-       if ( *_root == NULL ) *_root = *_sibling;\r
-}\r
-\r
-/* make a new AST node.  Make the newly-created\r
- * node the root for the current sibling list.  If a root node already\r
- * exists, make the newly-created node the root of the current root.\r
- */\r
-void\r
-ASTBase::subroot(ASTBase **_root, ASTBase **_sibling, ASTBase **_tail)\r
-{\r
-       if ( *_root != NULL )\r
-               if ( (*_root)->_down == *_sibling ) *_sibling = *_tail = *_root;\r
-       *_root = this;\r
-       (*_root)->_down = *_sibling;\r
-}\r
-\r
-/* Apply preorder_action(), etc.. to root then each sibling */\r
-//\r
-//  7-Apr-97 133MR1\r
-//     Fix suggested by Ron House (house@helios.usq.edu.au)\r
-//\r
-void\r
-ASTBase::preorder(void* pData /*= NULL*/ /* MR23 */)\r
-{\r
-       ASTBase *tree = this;\r
-\r
-       while ( tree!= NULL )\r
-       {\r
-               if ( tree->_down != NULL ) {\r
-                       tree->preorder_before_action(pData);            // MR1  \r
-               };\r
-               tree->preorder_action(pData);\r
-               if ( tree->_down!=NULL )\r
-               {\r
-                       tree->_down->preorder(pData);\r
-                       tree->preorder_after_action(pData);                     // MR1\r
-               }\r
-               tree = tree->_right;\r
-       }\r
-}\r
-\r
-/* free all AST nodes in tree; apply func to each before freeing */\r
-void\r
-ASTBase::destroy()\r
-{\r
-   ASTBase* tree = this;\r
-   while (tree) {\r
-      if (tree->_down) tree->_down->destroy();\r
-\r
-      ASTBase* cur = tree;\r
-      tree = tree->_right;\r
-      delete cur;\r
-   }\r
-}\r
-\r
-/* build a tree (root child1 child2 ... NULL)\r
- * If root is NULL, simply make the children siblings and return ptr\r
- * to 1st sibling (child1).  If root is not single node, return NULL.\r
- *\r
- * Siblings that are actually siblins lists themselves are handled\r
- * correctly.  For example #( NULL, #( NULL, A, B, C), D) results\r
- * in the tree ( NULL A B C D ).\r
- *\r
- * Requires at least two parameters with the last one being NULL.  If\r
- * both are NULL, return NULL.\r
- */\r
-ASTBase *\r
-ASTBase::tmake(ASTBase *root, ...)\r
-{\r
-       va_list ap;\r
-       register ASTBase *child, *sibling=NULL, *tail=NULL /*MR23*/, *w;\r
-\r
-       va_start(ap, root);\r
-\r
-       if ( root != NULL )\r
-               if ( root->_down != NULL ) {  \r
-            root->reportOverwriteOfDownPointer();  /* MR21 Report problem which almost always an error */\r
-            return NULL;\r
-        }\r
-       child = va_arg(ap, ASTBase *);\r
-       while ( child != NULL )\r
-       {\r
-               for (w=child; w->_right!=NULL; w=w->_right) {;} /* find end of child */\r
-               if ( sibling == NULL ) {sibling = child; tail = w;}\r
-               else {tail->_right = child; tail = w;}\r
-               child = va_arg(ap, ASTBase *);\r
-       }\r
-       if ( root==NULL ) root = sibling;\r
-       else root->_down = sibling;\r
-       va_end(ap);\r
-       return root;\r
-}\r
-\r
-#ifndef PCCTS_NOT_USING_SOR\r
-\r
-/* tree duplicate */\r
-// forgot to check for NULL this (TJP July 23,1995)\r
-ASTBase *\r
-ASTBase::dup()\r
-{\r
-       ASTBase *u, *t=this;\r
-       \r
-       if ( t == NULL ) return NULL;\r
-/*\r
-       u = new ASTBase;\r
-       *u = *t;\r
-*/\r
-       u = (ASTBase *)this->shallowCopy();\r
-       if ( t->_right!=NULL ) u->_right = t->_right->dup();\r
-       else u->_right = NULL;\r
-       if ( t->_down!=NULL ) u->_down = t->_down->dup();\r
-       else u->_down = NULL;\r
-       return u;\r
-}\r
-#endif\r
-\r
-//\r
-//  7-Apr-97 133MR1\r
-//          Fix suggested by Asgeir Olafsson (olafsson@cstar.ac.com)\r
-//\r
-/* tree duplicate */\r
-\r
-#ifndef PCCTS_NOT_USING_SOR\r
-\r
-ASTBase *\r
-ASTDoublyLinkedBase::dup()\r
-{\r
-       ASTDoublyLinkedBase *u, *t=this;\r
-       \r
-       if ( t == NULL ) return NULL;\r
-       u = (ASTDoublyLinkedBase *)this->shallowCopy();\r
-       u->_up = NULL;          /* set by calling invocation */\r
-       u->_left = NULL;\r
-       if (t->_right!=NULL) {                                          // MR1\r
-          u->_right=t->_right->dup();                                  // MR1\r
-         ((ASTDoublyLinkedBase *)u->_right)->_left = u;                // MR1\r
-        } else {                                                       // MR1\r
-         u->_right = NULL;                                             // MR1\r
-        };                                                             // MR1\r
-       if (t->_down!=NULL) {                                           // MR1\r
-         u->_down = t->_down->dup();                                   // MR1\r
-          ((ASTDoublyLinkedBase *)u->_down)->_up = u;                  // MR1\r
-        } else {                                                       // MR1\r
-         u->_down = NULL;                                              // MR1\r
-        };                                                             // MR1\r
-       return u;\r
-}\r
-\r
-#endif\r
-\r
-/*\r
- * Set the 'up', and 'left' pointers of all nodes in 't'.\r
- * Initial call is double_link(your_tree, NULL, NULL).\r
- */\r
-void\r
-ASTDoublyLinkedBase::double_link(ASTBase *left, ASTBase *up)\r
-{\r
-    ASTDoublyLinkedBase *t = this;\r
-\r
-    t->_left = (ASTDoublyLinkedBase *) left;\r
-    t->_up = (ASTDoublyLinkedBase *) up;\r
-    if (t->_down != NULL)\r
-               ((ASTDoublyLinkedBase *)t->_down)->double_link(NULL, t);\r
-    if (t->_right != NULL)\r
-               ((ASTDoublyLinkedBase *)t->_right)->double_link(t, up);\r
-}\r
-\r
-// MR21 ASTBase::reportOverwriteOfDownPointer\r
-\r
-void ASTBase::reportOverwriteOfDownPointer()\r
-{\r
-    panic("Attempt to overwrite down pointer in ASTBase::tmake");\r
-}\r
-\r
-// MR21 ASTBase::panic\r
-\r
-void ASTBase::panic(const char *msg)\r
-{\r
-       /* MR23 */ printMessage(stderr,"ASTBase panic: %s\n", msg);\r
-       exit(PCCTS_EXIT_FAILURE);\r
-}\r
-\r
-#ifdef PCCTS_NOT_USING_SOR\r
-//MR23\r
-int ASTBase::printMessage(FILE* pFile, const char* pFormat, ...)\r
-{\r
-       va_list marker;\r
-       va_start( marker, pFormat );\r
-       int iRet = vfprintf(pFile, pFormat, marker);\r
-       va_end( marker );\r
-       return iRet;\r
-}\r
-#endif\r