summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/ASTInspector.h
diff options
context:
space:
mode:
authorJustyna Ilczuk <justyna.ilczuk@gmail.com>2013-01-04 11:58:59 +0100
committerJustyna Ilczuk <justyna.ilczuk@gmail.com>2013-01-04 11:58:59 +0100
commit02bced0b5dbcd1dc9ccdc6f7bcd5c7ba09b28179 (patch)
treebcf89c39753a616d6b477c5e01b40ccee1a5e312 /Sencha-lang/ASTInspector.h
parent0992a3a67db500c2ed88218e47043482ab3829ac (diff)
downloadsencha-lang-02bced0b5dbcd1dc9ccdc6f7bcd5c7ba09b28179.tar.gz
sencha-lang-02bced0b5dbcd1dc9ccdc6f7bcd5c7ba09b28179.tar.bz2
sencha-lang-02bced0b5dbcd1dc9ccdc6f7bcd5c7ba09b28179.tar.xz
sencha-lang-02bced0b5dbcd1dc9ccdc6f7bcd5c7ba09b28179.zip
Some documentation and little refactoring.
Diffstat (limited to 'Sencha-lang/ASTInspector.h')
-rw-r--r--Sencha-lang/ASTInspector.h34
1 files changed, 32 insertions, 2 deletions
diff --git a/Sencha-lang/ASTInspector.h b/Sencha-lang/ASTInspector.h
index a77f4a1..6e399dd 100644
--- a/Sencha-lang/ASTInspector.h
+++ b/Sencha-lang/ASTInspector.h
@@ -11,18 +11,41 @@
#include <map>
#include "Visitor.h"
#include "AST/AllTypesOfASTNodes.h"
+/**
+ * ASTInspector is a class which is used to inspect nodes of AST.
+ * It's very useful. It provides user information about structure of the AST, how
+ * particular nodes are built, and some other information, more statistical such as,
+ * how many particular nodes is in tree. Thanks to depth awareness output can
+ * be well formatted. Every node is visited in different manner.
+ */
class ASTInspector: public Visitor {
public:
ASTInspector();
unsigned int how_many_visits() { return number_of_visits; }
+ /**
+ * For instance: how_many_occurences_of("BasicExpression") return how many times ASTInspector has encountered
+ * BasicExpression node.
+ */
unsigned int how_many_occurences_of(std::string type);
+
+ /**
+ * get_report() returns inspection report. To get report, you first have to
+ * visit some tree, using "visit" function.
+ */
std::string get_report() { return this->inspection_report; }
virtual ~ASTInspector();
+
+ /**
+ * forget_everything() erases all data which ASTInspector got during inspection.
+ * It's useful when we want to use ASTInspector for more trees than one, and data from previous
+ * shouldn't mix with data from current one.
+ */
void forget_everything();
+
void visit(Visitable * node);
- void visit(ProgramNode * node);
+
private:
unsigned int number_of_visits;
@@ -31,13 +54,20 @@ private:
std::string inspection_report;
unsigned int depth_level;
std::string compute_indent();
+
+ /**
+ * write_report is an internal method used for
+ * generating report in incremental way, using
+ * notes from current visits and formatting it on right depth_level.
+ */
void write_report(std::string visit_notes);
+
+ void visit(ProgramNode * node);
void visit(ConstantExpression * node);
void visit(BasicExpression * node);
void visit(UnaryExpression * node);
void visit(PostfixExpression * node);
void visit(WhileNode * node);
-
void visit(BasicStatement * node);
void visit(DeclarationStatement * node);
void visit(Assignment * node);