2012-12-17 22:59:16 +00:00
|
|
|
/*
|
|
|
|
* ASTInspector.h
|
|
|
|
*
|
|
|
|
* Created on: Dec 17, 2012
|
|
|
|
* Author: att
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ASTINSPECTOR_H_
|
|
|
|
#define ASTINSPECTOR_H_
|
|
|
|
|
2012-12-17 23:08:50 +00:00
|
|
|
#include <map>
|
2012-12-17 22:59:16 +00:00
|
|
|
#include "Visitor.h"
|
2012-12-17 23:08:50 +00:00
|
|
|
#include "AST/AllTypesOfASTNodes.h"
|
2012-12-17 22:59:16 +00:00
|
|
|
|
|
|
|
class ASTInspector: public Visitor {
|
|
|
|
public:
|
|
|
|
ASTInspector();
|
2012-12-21 15:16:39 +00:00
|
|
|
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; }
|
|
|
|
void visit(Visitable * node);
|
|
|
|
virtual ~ASTInspector();
|
|
|
|
void forget_everything();
|
2012-12-17 23:08:50 +00:00
|
|
|
|
2012-12-21 15:16:39 +00:00
|
|
|
private:
|
|
|
|
unsigned int number_of_visits;
|
|
|
|
typedef unsigned int NumberOfNodes;
|
2012-12-17 23:08:50 +00:00
|
|
|
std::map<std::string, NumberOfNodes> occurences;
|
2012-12-18 19:55:45 +00:00
|
|
|
std::string inspection_report;
|
|
|
|
unsigned int depth_level;
|
2012-12-21 15:16:39 +00:00
|
|
|
std::string compute_indent();
|
|
|
|
void write_report(std::string visit_notes);
|
2012-12-22 08:07:13 +00:00
|
|
|
void visit(ConstantExpression & node);
|
|
|
|
void visit(BasicExpression & node);
|
|
|
|
void visit(PostfixExpression & node);
|
|
|
|
void visit(WhileNode & node);
|
|
|
|
void visit(ProgramNode & node);
|
|
|
|
void visit(BasicStatement & node);
|
|
|
|
void visit(DeclarationStatement & node);
|
2012-12-17 23:08:50 +00:00
|
|
|
|
2012-12-17 22:59:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* ASTINSPECTOR_H_ */
|