summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/AST
diff options
context:
space:
mode:
authorJustyna Ilczuk <justyna.ilczuk@gmail.com>2012-12-18 22:41:39 +0100
committerJustyna Ilczuk <justyna.ilczuk@gmail.com>2012-12-18 22:41:39 +0100
commit736458f1fd5508b48602feae215749d2db73ebc5 (patch)
treedd56f48a1b7e3e8eb171cc6344240b4208e92c33 /Sencha-lang/AST
parent442d8c640fdde22d9f6bf5d1a729d8e17e2fa407 (diff)
downloadsencha-lang-736458f1fd5508b48602feae215749d2db73ebc5.tar.gz
sencha-lang-736458f1fd5508b48602feae215749d2db73ebc5.tar.bz2
sencha-lang-736458f1fd5508b48602feae215749d2db73ebc5.tar.xz
sencha-lang-736458f1fd5508b48602feae215749d2db73ebc5.zip
This crazy setup compiles. However I encountered some problems with
polymorphism. It probably doesn't work as I thought it would. Not problem at all :).
Diffstat (limited to 'Sencha-lang/AST')
-rw-r--r--Sencha-lang/AST/ASTNode.h4
-rw-r--r--Sencha-lang/AST/BasicExpression.cpp4
-rw-r--r--Sencha-lang/AST/BasicExpression.h2
-rw-r--r--Sencha-lang/AST/BasicStatement.h2
-rw-r--r--Sencha-lang/AST/ConstantExpression.h2
-rw-r--r--Sencha-lang/AST/ProgramNode.cpp7
-rw-r--r--Sencha-lang/AST/ProgramNode.h1
7 files changed, 17 insertions, 5 deletions
diff --git a/Sencha-lang/AST/ASTNode.h b/Sencha-lang/AST/ASTNode.h
index feee8bd..6a16f96 100644
--- a/Sencha-lang/AST/ASTNode.h
+++ b/Sencha-lang/AST/ASTNode.h
@@ -12,13 +12,13 @@
#include "SenchaObject.h"
#include "../Visitor.h"
-class ASTNode {
+class ASTNode : public Visitable{
public:
ASTNode();
ASTNode * parent;
std::vector<ASTNode *> children;
- virtual void accept(Visitor *) = 0;
+ virtual void accept(Visitor * visitor){ visitor->visit(this); };
virtual std::string debug() = 0;
virtual void execute() = 0;
diff --git a/Sencha-lang/AST/BasicExpression.cpp b/Sencha-lang/AST/BasicExpression.cpp
index 46a9d75..d5bf0f3 100644
--- a/Sencha-lang/AST/BasicExpression.cpp
+++ b/Sencha-lang/AST/BasicExpression.cpp
@@ -102,6 +102,10 @@ BasicExpression::~BasicExpression() {
}
+void BasicExpression::accept(Visitor * visitor)
+{
+ visitor->visit(this);
+}
std::string BasicExpression::debug()
{
diff --git a/Sencha-lang/AST/BasicExpression.h b/Sencha-lang/AST/BasicExpression.h
index c563f1d..cdb0b68 100644
--- a/Sencha-lang/AST/BasicExpression.h
+++ b/Sencha-lang/AST/BasicExpression.h
@@ -24,7 +24,7 @@ public:
std::string debug() ;
- void accept(Visitor * visitor);
+ virtual void accept(Visitor * visitor);
BasicExpression(ASTNode * parent);
virtual ~BasicExpression();
diff --git a/Sencha-lang/AST/BasicStatement.h b/Sencha-lang/AST/BasicStatement.h
index a34c4e7..1b616dc 100644
--- a/Sencha-lang/AST/BasicStatement.h
+++ b/Sencha-lang/AST/BasicStatement.h
@@ -10,6 +10,7 @@
#include <iostream>
#include "ASTExpression.h"
#include "ASTStatement.h"
+#include "../Visitor.h"
class BasicStatement : public ASTStatement {
public:
@@ -17,6 +18,7 @@ public:
virtual std::string debug();
void add_expression(ASTExpression * expr);
virtual void execute();
+ virtual void accept(Visitor * vistitor);
virtual ~BasicStatement();
};
diff --git a/Sencha-lang/AST/ConstantExpression.h b/Sencha-lang/AST/ConstantExpression.h
index 5529c72..a728efd 100644
--- a/Sencha-lang/AST/ConstantExpression.h
+++ b/Sencha-lang/AST/ConstantExpression.h
@@ -66,7 +66,7 @@ public:
std::string debug();
/** Implements visitor pattern */
- void accept(Visitor * visitor);
+ virtual void accept(Visitor * visitor);
virtual ~ConstantExpression();
diff --git a/Sencha-lang/AST/ProgramNode.cpp b/Sencha-lang/AST/ProgramNode.cpp
index 9d61a4d..aced5bf 100644
--- a/Sencha-lang/AST/ProgramNode.cpp
+++ b/Sencha-lang/AST/ProgramNode.cpp
@@ -26,9 +26,14 @@ void ProgramNode::execute() {
}
}
+void ProgramNode::accept(Visitor * visitor)
+{
+ visitor->visit(this);
+}
+
void ProgramNode::execute_last()
{
- children[children.size() -1]->execute();
+ children[children.size() - 1]->execute();
}
std::string ProgramNode::debug()
diff --git a/Sencha-lang/AST/ProgramNode.h b/Sencha-lang/AST/ProgramNode.h
index 1232699..80425df 100644
--- a/Sencha-lang/AST/ProgramNode.h
+++ b/Sencha-lang/AST/ProgramNode.h
@@ -19,6 +19,7 @@ public:
virtual ~ProgramNode();
virtual void execute();
virtual void execute_last();
+ virtual void accept(Visitor * visitor);
};
#endif /* PROGRAMNODE_H_ */