sencha-lang/Sencha-lang/AST/ASTNode.h

39 lines
911 B
C
Raw Normal View History

2012-11-17 16:02:32 +00:00
/*
* ASTNode.h
*
* Created on: Nov 4, 2012
* Author: attero
*/
#ifndef ASTNODE_H_
#define ASTNODE_H_
#include <vector>
#include <string>
#include "../Elements/SenchaObject.h"
2012-12-17 22:59:16 +00:00
#include "../Visitor.h"
2012-11-17 16:02:32 +00:00
/**
* ASTNode is an ancestor of all former ASTNodes.
* It implements Visitable, which is an abstraction of something, which
* can be visited, by visitor.
* It is very important in our tree relation and creating tree crawlers,
* such as ASTInspector, which is very helpful for debugging.
* ASTNode stores its children in vector of pointers to other ASTNodes,
* It allows us to use features of polymorphism.
*/
class ASTNode : public Visitable
{
2012-11-17 16:02:32 +00:00
public:
ASTNode();
std::vector<ASTNode *> children;
virtual void accept(Visitor * visitor){ visitor->visit(this); };
virtual SenchaObject evaluate() = 0;
virtual SenchaObject execute() = 0;
2012-11-17 16:02:32 +00:00
virtual ~ASTNode();
};
#endif /* ASTNODE_H_ */