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

39 lines
911 B
C++

/*
* ASTNode.h
*
* Created on: Nov 4, 2012
* Author: attero
*/
#ifndef ASTNODE_H_
#define ASTNODE_H_
#include <vector>
#include <string>
#include "../Elements/SenchaObject.h"
#include "../Visitor.h"
/**
* 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
{
public:
ASTNode();
std::vector<ASTNode *> children;
virtual void accept(Visitor * visitor){ visitor->visit(this); };
virtual SenchaObject evaluate() = 0;
virtual SenchaObject execute() = 0;
virtual ~ASTNode();
};
#endif /* ASTNODE_H_ */