From cc3e55c8885ca2ea145b5a811f038d7e4128b1ee Mon Sep 17 00:00:00 2001 From: Justyna Ilczuk Date: Mon, 17 Dec 2012 23:59:16 +0100 Subject: [PATCH] I'm starting visitors pattern. --- Sencha-lang/AST/ASTNode.h | 2 ++ Sencha-lang/ASTInspector.cpp | 18 ++++++++++++++++++ Sencha-lang/ASTInspector.h | 19 +++++++++++++++++++ Sencha-lang/Visitor.cpp | 18 ++++++++++++++++++ Sencha-lang/Visitor.h | 19 +++++++++++++++++++ 5 files changed, 76 insertions(+) create mode 100644 Sencha-lang/ASTInspector.cpp create mode 100644 Sencha-lang/ASTInspector.h create mode 100644 Sencha-lang/Visitor.cpp create mode 100644 Sencha-lang/Visitor.h diff --git a/Sencha-lang/AST/ASTNode.h b/Sencha-lang/AST/ASTNode.h index 7afe190..feee8bd 100644 --- a/Sencha-lang/AST/ASTNode.h +++ b/Sencha-lang/AST/ASTNode.h @@ -10,6 +10,7 @@ #include #include #include "SenchaObject.h" +#include "../Visitor.h" class ASTNode { public: @@ -17,6 +18,7 @@ public: ASTNode * parent; std::vector children; + virtual void accept(Visitor *) = 0; virtual std::string debug() = 0; virtual void execute() = 0; diff --git a/Sencha-lang/ASTInspector.cpp b/Sencha-lang/ASTInspector.cpp new file mode 100644 index 0000000..de4edbe --- /dev/null +++ b/Sencha-lang/ASTInspector.cpp @@ -0,0 +1,18 @@ +/* + * ASTInspector.cpp + * + * Created on: Dec 17, 2012 + * Author: att + */ + +#include "ASTInspector.h" + +ASTInspector::ASTInspector() { + // TODO Auto-generated constructor stub + +} + +ASTInspector::~ASTInspector() { + // TODO Auto-generated destructor stub +} + diff --git a/Sencha-lang/ASTInspector.h b/Sencha-lang/ASTInspector.h new file mode 100644 index 0000000..941c82e --- /dev/null +++ b/Sencha-lang/ASTInspector.h @@ -0,0 +1,19 @@ +/* + * ASTInspector.h + * + * Created on: Dec 17, 2012 + * Author: att + */ + +#ifndef ASTINSPECTOR_H_ +#define ASTINSPECTOR_H_ + +#include "Visitor.h" + +class ASTInspector: public Visitor { +public: + ASTInspector(); + virtual ~ASTInspector(); +}; + +#endif /* ASTINSPECTOR_H_ */ diff --git a/Sencha-lang/Visitor.cpp b/Sencha-lang/Visitor.cpp new file mode 100644 index 0000000..1fa2479 --- /dev/null +++ b/Sencha-lang/Visitor.cpp @@ -0,0 +1,18 @@ +/* + * Visitor.cpp + * + * Created on: Dec 17, 2012 + * Author: att + */ + +#include "Visitor.h" + +Visitor::Visitor() { + // TODO Auto-generated constructor stub + +} + +Visitor::~Visitor() { + // TODO Auto-generated destructor stub +} + diff --git a/Sencha-lang/Visitor.h b/Sencha-lang/Visitor.h new file mode 100644 index 0000000..85d4dfa --- /dev/null +++ b/Sencha-lang/Visitor.h @@ -0,0 +1,19 @@ +/* + * Visitor.h + * + * Created on: Dec 17, 2012 + * Author: att + */ + +#ifndef VISITOR_H_ +#define VISITOR_H_ +#include "AST/ASTNode.h" + +class Visitor { +public: + Visitor(); + virtual void visit(ASTNode * node/*something*/) = 0; + virtual ~Visitor(); +}; + +#endif /* VISITOR_H_ */