From 4537c91f3cf452295a3fbd2696045bcc16aaa3db Mon Sep 17 00:00:00 2001 From: jimtahu Date: Fri, 26 Apr 2013 17:18:26 -0500 Subject: [PATCH] Added classes for the syntax tree --- AssingmentStatement.cpp | 21 +++++++++++++++++++++ AssingmentStatement.h | 26 ++++++++++++++++++++++++++ BinOpValue.cpp | 22 ++++++++++++++++++++++ BinOpValue.h | 26 ++++++++++++++++++++++++++ ExitStatement.cpp | 21 +++++++++++++++++++++ ExitStatement.h | 22 ++++++++++++++++++++++ Identifier.cpp | 26 ++++++++++++++++++++++++++ Identifier.h | 26 ++++++++++++++++++++++++++ Makefile | 2 +- Node.cpp | 21 +++++++++++++++++++++ Node.h | 20 ++++++++++++++++++++ PrintStatement.cpp | 20 ++++++++++++++++++++ PrintStatement.h | 25 +++++++++++++++++++++++++ Statement.cpp | 28 ++++++++++++++++++++++++++++ Statement.h | 23 +++++++++++++++++++++++ StringValue.cpp | 26 ++++++++++++++++++++++++++ StringValue.h | 25 +++++++++++++++++++++++++ Value.cpp | 25 +++++++++++++++++++++++++ Value.h | 24 ++++++++++++++++++++++++ 19 files changed, 428 insertions(+), 1 deletion(-) create mode 100644 AssingmentStatement.cpp create mode 100644 AssingmentStatement.h create mode 100644 BinOpValue.cpp create mode 100644 BinOpValue.h create mode 100644 ExitStatement.cpp create mode 100644 ExitStatement.h create mode 100644 Identifier.cpp create mode 100644 Identifier.h create mode 100644 Node.cpp create mode 100644 Node.h create mode 100644 PrintStatement.cpp create mode 100644 PrintStatement.h create mode 100644 Statement.cpp create mode 100644 Statement.h create mode 100644 StringValue.cpp create mode 100644 StringValue.h create mode 100644 Value.cpp create mode 100644 Value.h diff --git a/AssingmentStatement.cpp b/AssingmentStatement.cpp new file mode 100644 index 0000000..363eccc --- /dev/null +++ b/AssingmentStatement.cpp @@ -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 */ diff --git a/AssingmentStatement.h b/AssingmentStatement.h new file mode 100644 index 0000000..84229e8 --- /dev/null +++ b/AssingmentStatement.h @@ -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_ */ diff --git a/BinOpValue.cpp b/BinOpValue.cpp new file mode 100644 index 0000000..a057d27 --- /dev/null +++ b/BinOpValue.cpp @@ -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 */ diff --git a/BinOpValue.h b/BinOpValue.h new file mode 100644 index 0000000..64d36e1 --- /dev/null +++ b/BinOpValue.h @@ -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_ */ diff --git a/ExitStatement.cpp b/ExitStatement.cpp new file mode 100644 index 0000000..8d010aa --- /dev/null +++ b/ExitStatement.cpp @@ -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 */ diff --git a/ExitStatement.h b/ExitStatement.h new file mode 100644 index 0000000..9609220 --- /dev/null +++ b/ExitStatement.h @@ -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_ */ diff --git a/Identifier.cpp b/Identifier.cpp new file mode 100644 index 0000000..3c3a8bb --- /dev/null +++ b/Identifier.cpp @@ -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 */ diff --git a/Identifier.h b/Identifier.h new file mode 100644 index 0000000..aa13094 --- /dev/null +++ b/Identifier.h @@ -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_ */ diff --git a/Makefile b/Makefile index 48de3db..dbbb3db 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CXX=distcc g++ +CXX=distcc clang++ #CFLAGS= -O2 -pipe -march=native CFLAGS=-ggdb CXXFLAGS=$(CFLAGS) diff --git a/Node.cpp b/Node.cpp new file mode 100644 index 0000000..b53e6de --- /dev/null +++ b/Node.cpp @@ -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 */ diff --git a/Node.h b/Node.h new file mode 100644 index 0000000..98be4f5 --- /dev/null +++ b/Node.h @@ -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_ */ diff --git a/PrintStatement.cpp b/PrintStatement.cpp new file mode 100644 index 0000000..542a7bf --- /dev/null +++ b/PrintStatement.cpp @@ -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 */ diff --git a/PrintStatement.h b/PrintStatement.h new file mode 100644 index 0000000..fc47e0e --- /dev/null +++ b/PrintStatement.h @@ -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_ */ diff --git a/Statement.cpp b/Statement.cpp new file mode 100644 index 0000000..232f042 --- /dev/null +++ b/Statement.cpp @@ -0,0 +1,28 @@ +/* + * Statement.cpp + * + * Created on: Apr 26, 2013 + * Author: jimtahu + */ + +#include "Statement.h" + +#include + +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 */ diff --git a/Statement.h b/Statement.h new file mode 100644 index 0000000..e58baa9 --- /dev/null +++ b/Statement.h @@ -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_ */ diff --git a/StringValue.cpp b/StringValue.cpp new file mode 100644 index 0000000..09eeba6 --- /dev/null +++ b/StringValue.cpp @@ -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 */ diff --git a/StringValue.h b/StringValue.h new file mode 100644 index 0000000..1665463 --- /dev/null +++ b/StringValue.h @@ -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_ */ diff --git a/Value.cpp b/Value.cpp new file mode 100644 index 0000000..0171155 --- /dev/null +++ b/Value.cpp @@ -0,0 +1,25 @@ +/* + * Value.cpp + * + * Created on: Apr 26, 2013 + * Author: jimtahu + */ + +#include "Value.h" + +namespace ParseTree { + +Value::Value() { + // TODO Auto-generated constructor stub + +} + +std::string Value::getValue(){ + return "ABSTRACT VALUE"; +} + +Value::~Value() { + // TODO Auto-generated destructor stub +} + +} /* namespace ParseTree */ diff --git a/Value.h b/Value.h new file mode 100644 index 0000000..05cd7e5 --- /dev/null +++ b/Value.h @@ -0,0 +1,24 @@ +/* + * Value.h + * + * Created on: Apr 26, 2013 + * Author: jimtahu + */ + +#ifndef VALUE_H_ +#define VALUE_H_ + +#include +#include "Node.h" + +namespace ParseTree { + +class Value: public ParseTree::Node { +public: + Value(); + virtual std::string getValue(); + virtual ~Value(); +}; + +} /* namespace ParseTree */ +#endif /* VALUE_H_ */