added ASTNode, updated Makefile

git-svn-id: svn://anubis/misc/llvm@76 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
josh 2008-11-07 05:04:42 +00:00
parent 807543fea1
commit 91db46aaec
4 changed files with 30 additions and 1 deletions

15
jlc/ASTNode.cc Normal file
View File

@ -0,0 +1,15 @@
#include "ASTNode.h"
ASTNode::~ASTNode()
{
/* clean up any children nodes */
int sz = myChildren.size();
for (int i = 0; i < sz; i++)
delete myChildren[i];
}
void ASTNode::addChild(ASTNode * node)
{
myChildren.push_back(node);
}

13
jlc/ASTNode.h Normal file
View File

@ -0,0 +1,13 @@
#include <vector>
class ASTNode
{
public:
virtual ~ASTNode();
void addChild(ASTNode * node);
std::vector<ASTNode *> & getChildren() { return myChildren; }
private:
std::vector<ASTNode *> myChildren;
};

View File

@ -7,6 +7,7 @@ LDFLAGS := -lfl
COBJS := lex.yy.o
CXXOBJS := $(TARGET).tab.o
CXXOBJS += ASTNode.o
all: $(TARGET)

View File

@ -152,7 +152,7 @@ assignment: ID ASSIGN number SEMICOLON ;
int main(int argc, char * argv[])
{
if (argc > 0)
if (argc > 1)
{
yyin = fopen(argv[1], "r");
if (yyin == NULL)