-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAstPrinter.h
62 lines (52 loc) · 1.49 KB
/
AstPrinter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef __ASTPRINTER_H__
#define __ASTPRINTER_H__
#include <iostream>
#include <fstream>
#include "Ast.h"
#include "SymTab.h"
using namespace std;
//extern SymTab *symTab;
extern int errorNum;
extern string fileName;
class AstPrinter: public AstVisitor {
private:
SymTab *symTab;
int indent;
int returnType;
map<string, vector<int> > parameterMap;
int parameterType;
int indexNum;
// indent for nested printing
void doIndent( int lev )
{
// indent
for( int i = 0; i < lev; i++ )
cout << " ";
}
public:
AstPrinter( int indentLevel )
{
indent = indentLevel;
}
void visit( MethodDeclaration *aDeclNode );
void visit( FieldDeclaration *aDeclNode );
void visit( ParameterDeclaration *aDeclNode );
void visit( VariableDeclaration *aDeclNode );
void visit( ClassDeclaration *aDeclNode );
void visit( LiteralExpression *anExpNode );
void visit( ReferenceExpression *anExpNode );
void visit( NewExpression *anExpNode );
void visit( UnaryExpression *anExpNode );
void visit( BinaryExpression *anExpNode );
void visit( CastExpression *anExpNode );
void visit( MethodCallExpression *anExpNode );
void visit( AssignStatement *anStmtNode );
void visit( WhileStatement *anStmtNode );
void visit( ForStatement *anStmtNode );
void visit( IfStatement *anStmtNode );
void visit( ReturnStatement *anStmtNode );
void visit( BlockStatement *anStmtNode );
void visit( MethodCallStatement *anStmtNode );
void visit( EmptyStatement *anStmtNode );
};
#endif