added ASTNode, updated Makefile
git-svn-id: svn://anubis/misc/llvm@76 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
parent
807543fea1
commit
91db46aaec
15
jlc/ASTNode.cc
Normal file
15
jlc/ASTNode.cc
Normal 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
13
jlc/ASTNode.h
Normal 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;
|
||||
};
|
@ -7,6 +7,7 @@ LDFLAGS := -lfl
|
||||
|
||||
COBJS := lex.yy.o
|
||||
CXXOBJS := $(TARGET).tab.o
|
||||
CXXOBJS += ASTNode.o
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user