sencha-lang/Sencha-lang/ASTInspector.h

56 lines
1.2 KiB
C++

/*
* ASTInspector.h
*
* Created on: Dec 17, 2012
* Author: att
*/
#ifndef ASTINSPECTOR_H_
#define ASTINSPECTOR_H_
#include <map>
#include "Visitor.h"
#include "AST/AllTypesOfASTNodes.h"
class ASTInspector: public Visitor {
public:
ASTInspector();
unsigned int how_many_visits() { return number_of_visits; }
unsigned int how_many_occurences_of(std::string type);
std::string get_report() { return this->inspection_report; }
virtual ~ASTInspector();
void forget_everything();
void visit(Visitable * node);
void visit(ProgramNode * node);
private:
unsigned int number_of_visits;
typedef unsigned int NumberOfNodes;
std::map<std::string, NumberOfNodes> occurences;
std::string inspection_report;
unsigned int depth_level;
std::string compute_indent();
void write_report(std::string visit_notes);
void visit(ConstantExpression * node);
void visit(BasicExpression * node);
void visit(PostfixExpression * node);
void visit(WhileNode * node);
void visit(BasicStatement * node);
void visit(DeclarationStatement * node);
void visit(Assignment * node);
void visit(IfNode * node);
void visit(IncorrectExpression * node);
void visit(RepeatStatement * node);
void visit(VariableExpression * node);
};
#endif /* ASTINSPECTOR_H_ */