From 6e376d5b1c25d72f2c3170b18b1bd279747d7260 Mon Sep 17 00:00:00 2001 From: Justyna Att Ilczuk Date: Sat, 17 Nov 2012 17:02:32 +0100 Subject: [PATCH] AST part moved into AST folder. --- Sencha-lang/.cproject | 22 +++++++++++++++------- Sencha-lang/AST/AST.cpp | 19 +++++++++++++++++++ Sencha-lang/AST/AST.h | 23 +++++++++++++++++++++++ Sencha-lang/AST/ASTExpression.cpp | 18 ++++++++++++++++++ Sencha-lang/AST/ASTExpression.h | 18 ++++++++++++++++++ Sencha-lang/AST/ASTNode.cpp | 18 ++++++++++++++++++ Sencha-lang/AST/ASTNode.h | 24 ++++++++++++++++++++++++ Sencha-lang/AST/ASTPrimary.cpp | 20 ++++++++++++++++++++ Sencha-lang/AST/ASTPrimary.h | 23 +++++++++++++++++++++++ Sencha-lang/AST/ASTProgram.cpp | 21 +++++++++++++++++++++ Sencha-lang/AST/ASTProgram.h | 22 ++++++++++++++++++++++ Sencha-lang/AST/ASTStatement.cpp | 18 ++++++++++++++++++ Sencha-lang/AST/ASTStatement.h | 18 ++++++++++++++++++ Sencha-lang/AST/AllTypesOfASTNodes.h | 20 ++++++++++++++++++++ 14 files changed, 277 insertions(+), 7 deletions(-) create mode 100644 Sencha-lang/AST/AST.cpp create mode 100644 Sencha-lang/AST/AST.h create mode 100644 Sencha-lang/AST/ASTExpression.cpp create mode 100644 Sencha-lang/AST/ASTExpression.h create mode 100644 Sencha-lang/AST/ASTNode.cpp create mode 100644 Sencha-lang/AST/ASTNode.h create mode 100644 Sencha-lang/AST/ASTPrimary.cpp create mode 100644 Sencha-lang/AST/ASTPrimary.h create mode 100644 Sencha-lang/AST/ASTProgram.cpp create mode 100644 Sencha-lang/AST/ASTProgram.h create mode 100644 Sencha-lang/AST/ASTStatement.cpp create mode 100644 Sencha-lang/AST/ASTStatement.h create mode 100644 Sencha-lang/AST/AllTypesOfASTNodes.h diff --git a/Sencha-lang/.cproject b/Sencha-lang/.cproject index cb07a7f..ef991be 100644 --- a/Sencha-lang/.cproject +++ b/Sencha-lang/.cproject @@ -43,7 +43,8 @@ - + + @@ -67,15 +68,15 @@ - + - - @@ -115,6 +116,13 @@ - + + + + + + + + diff --git a/Sencha-lang/AST/AST.cpp b/Sencha-lang/AST/AST.cpp new file mode 100644 index 0000000..d31be57 --- /dev/null +++ b/Sencha-lang/AST/AST.cpp @@ -0,0 +1,19 @@ +/* + * AST.cpp + * + * Created on: Nov 4, 2012 + * Author: attero + */ +#include "AST.h" +#include "AllTypesOfASTNodes.h" + +AST::AST() { + root = new ASTProgram(); + current_node = root; + number_of_nodes = 1; + level_of_depth = 0; +} + +AST::~AST() { +} + diff --git a/Sencha-lang/AST/AST.h b/Sencha-lang/AST/AST.h new file mode 100644 index 0000000..c29207e --- /dev/null +++ b/Sencha-lang/AST/AST.h @@ -0,0 +1,23 @@ +/* + * AST.h + * + * Created on: Nov 4, 2012 + * Author: attero + */ + +#ifndef AST_H_ +#define AST_H_ +#include "ASTNode.h" + +class AST { +public: + AST(); + ASTNode * root; + ASTNode * current_node; + int number_of_nodes; + int level_of_depth; + ASTNode * add_node(ASTNode * node); + virtual ~AST(); +}; + +#endif /* AST_H_ */ diff --git a/Sencha-lang/AST/ASTExpression.cpp b/Sencha-lang/AST/ASTExpression.cpp new file mode 100644 index 0000000..32a47d8 --- /dev/null +++ b/Sencha-lang/AST/ASTExpression.cpp @@ -0,0 +1,18 @@ +/* + * ASTExpression.cpp + * + * Created on: Nov 4, 2012 + * Author: attero + */ + +#include "ASTExpression.h" + +ASTExpression::ASTExpression() { + // TODO Auto-generated constructor stub + +} + +ASTExpression::~ASTExpression() { + // TODO Auto-generated destructor stub +} + diff --git a/Sencha-lang/AST/ASTExpression.h b/Sencha-lang/AST/ASTExpression.h new file mode 100644 index 0000000..69010ae --- /dev/null +++ b/Sencha-lang/AST/ASTExpression.h @@ -0,0 +1,18 @@ +/* + * ASTExpression.h + * + * Created on: Nov 4, 2012 + * Author: attero + */ + +#ifndef ASTEXPRESSION_H_ +#define ASTEXPRESSION_H_ +#include "ASTNode.h" + +class ASTExpression : public ASTNode { +public: + ASTExpression(); + virtual ~ASTExpression(); +}; + +#endif /* ASTEXPRESSION_H_ */ diff --git a/Sencha-lang/AST/ASTNode.cpp b/Sencha-lang/AST/ASTNode.cpp new file mode 100644 index 0000000..80429c2 --- /dev/null +++ b/Sencha-lang/AST/ASTNode.cpp @@ -0,0 +1,18 @@ +/* + * ASTNode.cpp + * + * Created on: Nov 4, 2012 + * Author: attero + */ + +#include "ASTNode.h" + +ASTNode::ASTNode() { + // TODO Auto-generated constructor stub + parent = 0; +} + +ASTNode::~ASTNode() { + // TODO Auto-generated destructor stub +} + diff --git a/Sencha-lang/AST/ASTNode.h b/Sencha-lang/AST/ASTNode.h new file mode 100644 index 0000000..b0145a3 --- /dev/null +++ b/Sencha-lang/AST/ASTNode.h @@ -0,0 +1,24 @@ +/* + * ASTNode.h + * + * Created on: Nov 4, 2012 + * Author: attero + */ + +#ifndef ASTNODE_H_ +#define ASTNODE_H_ +#include + +class ASTNode { +public: + ASTNode(); + ASTNode * parent; + std::vector children; + void add_children(ASTNode *); + void remove_most_right_children(); + void set_parent(ASTNode *); + virtual void execute() = 0; + virtual ~ASTNode(); +}; + +#endif /* ASTNODE_H_ */ diff --git a/Sencha-lang/AST/ASTPrimary.cpp b/Sencha-lang/AST/ASTPrimary.cpp new file mode 100644 index 0000000..c442ec5 --- /dev/null +++ b/Sencha-lang/AST/ASTPrimary.cpp @@ -0,0 +1,20 @@ +/* + * ASTPrimary.cpp + * + * Created on: Nov 4, 2012 + * Author: attero + */ + +#include "ASTPrimary.h" + +ASTPrimary::ASTPrimary(ASTNode * parent) { + // TODO Auto-generated constructor stub + value = ""; + this->parent = parent; +} + +ASTPrimary::~ASTPrimary() { + // TODO Auto-generated destructor stub +} + + diff --git a/Sencha-lang/AST/ASTPrimary.h b/Sencha-lang/AST/ASTPrimary.h new file mode 100644 index 0000000..9387a0a --- /dev/null +++ b/Sencha-lang/AST/ASTPrimary.h @@ -0,0 +1,23 @@ +/* + * ASTPrimary.h + * + * Created on: Nov 4, 2012 + * Author: attero + */ + +#ifndef ASTPRIMARY_H_ +#define ASTPRIMARY_H_ +#include "ASTNode.h" +#include + +class ASTPrimary : public ASTNode { +public: + ASTPrimary(ASTNode * parent); + + virtual ~ASTPrimary(); + virtual void execute() {}; + std::string value; + +}; + +#endif /* ASTPRIMARY_H_ */ diff --git a/Sencha-lang/AST/ASTProgram.cpp b/Sencha-lang/AST/ASTProgram.cpp new file mode 100644 index 0000000..8b74923 --- /dev/null +++ b/Sencha-lang/AST/ASTProgram.cpp @@ -0,0 +1,21 @@ +/* + * ASTProgram.cpp + * + * Created on: Nov 5, 2012 + * Author: attero + */ + +#include "ASTProgram.h" + +ASTProgram::ASTProgram() { + // TODO Auto-generated constructor stub + +} + +ASTProgram::~ASTProgram() { + // TODO Auto-generated destructor stub +} + +void ASTProgram::execute() { + std::cout << "Program started!\n"; +} diff --git a/Sencha-lang/AST/ASTProgram.h b/Sencha-lang/AST/ASTProgram.h new file mode 100644 index 0000000..f83bbf3 --- /dev/null +++ b/Sencha-lang/AST/ASTProgram.h @@ -0,0 +1,22 @@ +/* + * ASTProgram.h + * + * Created on: Nov 5, 2012 + * Author: attero + */ + +#ifndef ASTPROGRAM_H_ +#define ASTPROGRAM_H_ +#include +#include "ASTNode.h" +#include "ASTStatement.h" + +class ASTProgram : public ASTNode { +public: + ASTProgram(); + ASTStatement * add_child(ASTStatement * node); + virtual ~ASTProgram(); + virtual void execute(); +}; + +#endif /* ASTPROGRAM_H_ */ diff --git a/Sencha-lang/AST/ASTStatement.cpp b/Sencha-lang/AST/ASTStatement.cpp new file mode 100644 index 0000000..52c5526 --- /dev/null +++ b/Sencha-lang/AST/ASTStatement.cpp @@ -0,0 +1,18 @@ +/* + * ASTStatement.cpp + * + * Created on: Nov 4, 2012 + * Author: attero + */ + +#include "ASTStatement.h" + +ASTStatement::ASTStatement() { + // TODO Auto-generated constructor stub + +} + +ASTStatement::~ASTStatement() { + // TODO Auto-generated destructor stub +} + diff --git a/Sencha-lang/AST/ASTStatement.h b/Sencha-lang/AST/ASTStatement.h new file mode 100644 index 0000000..b2bfd84 --- /dev/null +++ b/Sencha-lang/AST/ASTStatement.h @@ -0,0 +1,18 @@ +/* + * ASTStatement.h + * + * Created on: Nov 4, 2012 + * Author: attero + */ + +#ifndef ASTSTATEMENT_H_ +#define ASTSTATEMENT_H_ +#include "ASTNode.h" + +class ASTStatement : public ASTNode { +public: + ASTStatement(); + virtual ~ASTStatement(); +}; + +#endif /* ASTSTATEMENT_H_ */ diff --git a/Sencha-lang/AST/AllTypesOfASTNodes.h b/Sencha-lang/AST/AllTypesOfASTNodes.h new file mode 100644 index 0000000..61051e6 --- /dev/null +++ b/Sencha-lang/AST/AllTypesOfASTNodes.h @@ -0,0 +1,20 @@ +/* + * AllTypesOfASTNodes.h + * + * Created on: Nov 5, 2012 + * Author: attero + */ + +#ifndef ALLTYPESOFASTNODES_H_ +#define ALLTYPESOFASTNODES_H_ + +#include "ASTNode.h" +#include "ASTProgram.h" +#include "ASTStatement.h" +#include "ASTExpression.h" +#include "ASTPrimary.h" + +//And probably more +//TODO actualize it + +#endif /* ALLTYPESOFASTNODES_H_ */