I'm starting visitors pattern.

functions
Justyna Ilczuk 2012-12-17 23:59:16 +01:00
parent ba6497e5a5
commit cc3e55c888
5 changed files with 76 additions and 0 deletions

View File

@ -10,6 +10,7 @@
#include <vector>
#include <string>
#include "SenchaObject.h"
#include "../Visitor.h"
class ASTNode {
public:
@ -17,6 +18,7 @@ public:
ASTNode * parent;
std::vector<ASTNode *> children;
virtual void accept(Visitor *) = 0;
virtual std::string debug() = 0;
virtual void execute() = 0;

View File

@ -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
}

View File

@ -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_ */

18
Sencha-lang/Visitor.cpp Normal file
View File

@ -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
}

19
Sencha-lang/Visitor.h Normal file
View File

@ -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_ */