I'm starting visitors pattern.
parent
ba6497e5a5
commit
cc3e55c888
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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_ */
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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_ */
|
Loading…
Reference in New Issue