Skip to content

Commit

Permalink
Added classes for the syntax tree
Browse files Browse the repository at this point in the history
  • Loading branch information
jimtahu committed Apr 26, 2013
1 parent aa8cb43 commit 4537c91
Show file tree
Hide file tree
Showing 19 changed files with 428 additions and 1 deletion.
21 changes: 21 additions & 0 deletions AssingmentStatement.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* AssingmentStatement.cpp
*
* Created on: Apr 26, 2013
* Author: jimtahu
*/

#include "AssingmentStatement.h"

namespace ParseTree {

AssingmentStatement::AssingmentStatement(Identifier *id, Value *value) {
this->id=id;
this->value=value;
}

AssingmentStatement::~AssingmentStatement() {
// TODO Auto-generated destructor stub
}

} /* namespace ParseTree */
26 changes: 26 additions & 0 deletions AssingmentStatement.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* AssingmentStatement.h
*
* Created on: Apr 26, 2013
* Author: jimtahu
*/

#ifndef ASSINGMENTSTATEMENT_H_
#define ASSINGMENTSTATEMENT_H_

#include "Statement.h"
#include "Identifier.h"

namespace ParseTree {

class AssingmentStatement: public ParseTree::Statement {
private:
Identifier *id;
Value *value;
public:
AssingmentStatement(Identifier *id, Value *value);
virtual ~AssingmentStatement();
};

} /* namespace ParseTree */
#endif /* ASSINGMENTSTATEMENT_H_ */
22 changes: 22 additions & 0 deletions BinOpValue.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* BinOpValue.cpp
*
* Created on: Apr 26, 2013
* Author: jimtahu
*/

#include "BinOpValue.h"

namespace ParseTree {

BinOpValue::BinOpValue(std::string op, Value *a, Value *b) {
this->op=op;
this->a=a;
this->b=b;
}

BinOpValue::~BinOpValue() {
// TODO Auto-generated destructor stub
}

} /* namespace ParseTree */
26 changes: 26 additions & 0 deletions BinOpValue.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* BinOpValue.h
*
* Created on: Apr 26, 2013
* Author: jimtahu
*/

#ifndef BINOPVALUE_H_
#define BINOPVALUE_H_

#include "Value.h"

namespace ParseTree {

class BinOpValue: public ParseTree::Value {
private:
std::string op;
Value *a;
Value *b;
public:
BinOpValue(std::string op, Value *a, Value *b);
virtual ~BinOpValue();
};

} /* namespace ParseTree */
#endif /* BINOPVALUE_H_ */
21 changes: 21 additions & 0 deletions ExitStatement.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* ExitStatement.cpp
*
* Created on: Apr 26, 2013
* Author: jimtahu
*/

#include "ExitStatement.h"

namespace ParseTree {

ExitStatement::ExitStatement() {
// TODO Auto-generated constructor stub

}

ExitStatement::~ExitStatement() {
// TODO Auto-generated destructor stub
}

} /* namespace ParseTree */
22 changes: 22 additions & 0 deletions ExitStatement.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* ExitStatement.h
*
* Created on: Apr 26, 2013
* Author: jimtahu
*/

#ifndef EXITSTATEMENT_H_
#define EXITSTATEMENT_H_

#include "Statement.h"

namespace ParseTree {

class ExitStatement: public ParseTree::Statement {
public:
ExitStatement();
virtual ~ExitStatement();
};

} /* namespace ParseTree */
#endif /* EXITSTATEMENT_H_ */
26 changes: 26 additions & 0 deletions Identifier.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Identifier.cpp
*
* Created on: Apr 26, 2013
* Author: jimtahu
*/

#include "Identifier.h"

namespace ParseTree {

using namespace std;

Identifier::Identifier(string name) {
this->Name = name;
}

string Identifier::getName(){
return this->Name;
}

Identifier::~Identifier() {
// TODO Auto-generated destructor stub
}

} /* namespace ParseTree */
26 changes: 26 additions & 0 deletions Identifier.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Identifier.h
*
* Created on: Apr 26, 2013
* Author: jimtahu
*/

#ifndef IDENTIFIER_H_
#define IDENTIFIER_H_

#include "Value.h"

namespace ParseTree {

class Identifier: public ParseTree::Value {
private:
std::string Name;
public:
Identifier(std::string name);
std::string getName();
void setValue(std::string value);
virtual ~Identifier();
};

} /* namespace ParseTree */
#endif /* IDENTIFIER_H_ */
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CXX=distcc g++
CXX=distcc clang++
#CFLAGS= -O2 -pipe -march=native
CFLAGS=-ggdb
CXXFLAGS=$(CFLAGS)
Expand Down
21 changes: 21 additions & 0 deletions Node.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Node.cpp
*
* Created on: Apr 26, 2013
* Author: jimtahu
*/

#include "Node.h"

namespace ParseTree {

Node::Node() {
// TODO Auto-generated constructor stub

}

Node::~Node() {
// TODO Auto-generated destructor stub
}

} /* namespace ParseTree */
20 changes: 20 additions & 0 deletions Node.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Node.h
*
* Created on: Apr 26, 2013
* Author: jimtahu
*/

#ifndef NODE_H_
#define NODE_H_

namespace ParseTree {

class Node {
public:
Node();
virtual ~Node();
};

} /* namespace ParseTree */
#endif /* NODE_H_ */
20 changes: 20 additions & 0 deletions PrintStatement.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* PrintStatement.cpp
*
* Created on: Apr 26, 2013
* Author: jimtahu
*/

#include "PrintStatement.h"

namespace ParseTree {

PrintStatement::PrintStatement(Value *output) {
this->value=output;
}

PrintStatement::~PrintStatement() {
// TODO Auto-generated destructor stub
}

} /* namespace ParseTree */
25 changes: 25 additions & 0 deletions PrintStatement.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* PrintStatement.h
*
* Created on: Apr 26, 2013
* Author: jimtahu
*/

#ifndef PRINTSTATEMENT_H_
#define PRINTSTATEMENT_H_

#include "Statement.h"
#include "Value.h"

namespace ParseTree {

class PrintStatement: public ParseTree::Statement {
private:
Value *value;
public:
PrintStatement(Value *output);
virtual ~PrintStatement();
};

} /* namespace ParseTree */
#endif /* PRINTSTATEMENT_H_ */
28 changes: 28 additions & 0 deletions Statement.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Statement.cpp
*
* Created on: Apr 26, 2013
* Author: jimtahu
*/

#include "Statement.h"

#include <iostream>

namespace ParseTree {

using namespace std;

Statement::Statement() {
cerr << "Creation of abstract statement" << endl;
}

void Statement::Execute(){
cerr << "Attempted execution of abstract statement" << endl;
}

Statement::~Statement() {
// TODO Auto-generated destructor stub
}

} /* namespace ParseTree */
23 changes: 23 additions & 0 deletions Statement.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Statement.h
*
* Created on: Apr 26, 2013
* Author: jimtahu
*/

#ifndef STATEMENT_H_
#define STATEMENT_H_

#include "Node.h"

namespace ParseTree {

class Statement: public ParseTree::Node {
public:
Statement();
virtual void Execute();
virtual ~Statement();
};

} /* namespace ParseTree */
#endif /* STATEMENT_H_ */
26 changes: 26 additions & 0 deletions StringValue.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* StringValue.cpp
*
* Created on: Apr 26, 2013
* Author: jimtahu
*/

#include "StringValue.h"

namespace ParseTree {

using namespace std;

StringValue::StringValue(string value) {
this->value = value;
}

string StringValue::getValue(){
return this->value;
}

StringValue::~StringValue() {
// TODO Auto-generated destructor stub
}

} /* namespace ParseTree */
25 changes: 25 additions & 0 deletions StringValue.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* StringValue.h
*
* Created on: Apr 26, 2013
* Author: jimtahu
*/

#ifndef STRINGVALUE_H_
#define STRINGVALUE_H_

#include "Value.h"

namespace ParseTree {

class StringValue: public ParseTree::Value {
private:
std::string value;
public:
StringValue(std::string value);
std::string getValue();
virtual ~StringValue();
};

} /* namespace ParseTree */
#endif /* STRINGVALUE_H_ */
Loading

0 comments on commit 4537c91

Please sign in to comment.