ASTBase.cpp revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
/* Abstract syntax tree manipulation functions
*
* SOFTWARE RIGHTS
*
* We reserve no LEGAL rights to the Purdue Compiler Construction Tool
* Set (PCCTS) -- PCCTS is in the public domain. An individual or
* company may do whatever they wish with source code distributed with
* PCCTS or the code generated by PCCTS, including the incorporation of
* PCCTS, or its output, into commerical software.
*
* We encourage users to develop software with PCCTS. However, we do ask
* that credit is given to us for developing PCCTS. By "credit",
* we mean that if you incorporate our source code into one of your
* programs (commercial product, research project, or otherwise) that you
* acknowledge this fact somewhere in the documentation, research report,
* etc... If you like PCCTS and have developed a nice tool with the
* output, please mention that you developed it using PCCTS. In
* addition, we ask that this header remain intact in our source code.
* As long as these guidelines are kept, we expect to continue enhancing
* this system and expect to make other tools available as they are
* completed.
*
* ANTLR 1.33
* Terence Parr
* Parr Research Corporation
* with Purdue University and AHPCRC, University of Minnesota
* 1989-2000
*/
#include "pcctscfg.h"
#include "pccts_stdio.h"
#include "pccts_stdarg.h"
#define ANTLR_SUPPORT_CODE
#include "ASTBase.h"
/* ensure that tree manipulation variables are current after a rule
* reference
*/
void
{
}
/* add a child node to the current sibling list */
void
{
else {
*_sibling = this;
}
*_tail = this;
}
/* make a new AST node. Make the newly-created
* node the root for the current sibling list. If a root node already
* exists, make the newly-created node the root of the current root.
*/
void
{
*_root = this;
}
/* Apply preorder_action(), etc.. to root then each sibling */
//
// 7-Apr-97 133MR1
// Fix suggested by Ron House (house@helios.usq.edu.au)
//
void
{
{
};
{
}
}
}
/* free all AST nodes in tree; apply func to each before freeing */
void
{
while (tree) {
delete cur;
}
}
/* build a tree (root child1 child2 ... NULL)
* If root is NULL, simply make the children siblings and return ptr
* to 1st sibling (child1). If root is not single node, return NULL.
*
* Siblings that are actually siblins lists themselves are handled
* correctly. For example #( NULL, #( NULL, A, B, C), D) results
* in the tree ( NULL A B C D ).
*
* Requires at least two parameters with the last one being NULL. If
* both are NULL, return NULL.
*/
ASTBase *
{
return NULL;
}
{
}
return root;
}
#ifndef PCCTS_NOT_USING_SOR
/* tree duplicate */
// forgot to check for NULL this (TJP July 23,1995)
ASTBase *
{
ASTBase *u, *t=this;
/*
u = new ASTBase;
*u = *t;
*/
u = (ASTBase *)this->shallowCopy();
return u;
}
#endif
//
// 7-Apr-97 133MR1
// Fix suggested by Asgeir Olafsson (olafsson@cstar.ac.com)
//
/* tree duplicate */
#ifndef PCCTS_NOT_USING_SOR
ASTBase *
{
ASTDoublyLinkedBase *u, *t=this;
u = (ASTDoublyLinkedBase *)this->shallowCopy();
} else { // MR1
}; // MR1
} else { // MR1
}; // MR1
return u;
}
#endif
/*
* Set the 'up', and 'left' pointers of all nodes in 't'.
* Initial call is double_link(your_tree, NULL, NULL).
*/
void
{
ASTDoublyLinkedBase *t = this;
}
// MR21 ASTBase::reportOverwriteOfDownPointer
void ASTBase::reportOverwriteOfDownPointer()
{
panic("Attempt to overwrite down pointer in ASTBase::tmake");
}
// MR21 ASTBase::panic
{
}
#ifdef PCCTS_NOT_USING_SOR
//MR23
{
return iRet;
}
#endif