annotate tools/AstPrinter.d @ 158:57b0b4464a0b

Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
author Anders Johnsen <skabet@gmail.com>
date Tue, 22 Jul 2008 00:33:58 +0200
parents 6ec686d9c87d
children 362265427838
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
1 module tools.AstPrinter;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
2
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
3 import tango.io.Stdout;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
4
94
48bb2287c035 Added Modules. Right now it's very simple - will grow with time and need.
Anders Johnsen <skabet@gmail.com>
parents: 88
diff changeset
5 import ast.Module,
48bb2287c035 Added Modules. Right now it's very simple - will grow with time and need.
Anders Johnsen <skabet@gmail.com>
parents: 88
diff changeset
6 ast.Decl,
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
7 ast.Stmt,
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
8 ast.Exp;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
9
144
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
10 import basic.SourceManager,
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
11 basic.Attribute;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
12
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
13 class AstPrinter
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
14 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
15 const char[] tabType = " "; // 4 spaces
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
16
88
eb5b2c719a39 Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents: 79
diff changeset
17 this(SourceManager sm)
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
18 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
19
88
eb5b2c719a39 Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents: 79
diff changeset
20 this.sm = sm;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
21 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
22
94
48bb2287c035 Added Modules. Right now it's very simple - will grow with time and need.
Anders Johnsen <skabet@gmail.com>
parents: 88
diff changeset
23 void print(Module m)
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
24 {
101
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 94
diff changeset
25 printBeginLine("module ");
144
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
26 print(m.moduleName);
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
27 printEndLine(";");
101
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 94
diff changeset
28 printEndLine();
94
48bb2287c035 Added Modules. Right now it's very simple - will grow with time and need.
Anders Johnsen <skabet@gmail.com>
parents: 88
diff changeset
29 foreach(decl ; m.decls)
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
30 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
31 printDecl(decl);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
32 }
101
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 94
diff changeset
33 printEndLine();
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
34 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
35
158
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
36 void printDecl(Decl decl, bool printAtt = true)
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
37 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
38 switch(decl.declType)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
39 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
40 case DeclType.FuncDecl:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
41 auto funcDecl = cast(FuncDecl)decl;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
42 printBeginLine();
158
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
43 if(printAtt) printAttribute(decl.att);
63
9f8131676242 Now Decl's have a DType type(), and should use varType and returnType to get the old type id
Anders Halager <halager@gmail.com>
parents: 60
diff changeset
44 printIdentifier(funcDecl.returnType);
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
45 space;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
46 printIdentifier(funcDecl.identifier);
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
47 printFuncArgs(funcDecl);
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
48 printOpenBrace();
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
49 foreach(stmt ; funcDecl.statements)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
50 printStatement(stmt);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
51 printCloseBrace();
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
52 break;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
53
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
54 case DeclType.VarDecl:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
55 auto varDecl = cast(VarDecl)decl;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
56 printBeginLine();
158
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
57 if(printAtt) printAttribute(decl.att);
77
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
58 printExp(varDecl.varType);
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
59 space;
77
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
60 printExp(varDecl.identifier);
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
61 if(varDecl.init)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
62 {
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
63 print(" = ");
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
64 printExp(varDecl.init);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
65 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
66 printEndLine(";");
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
67 break;
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
68
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
69 case DeclType.StructDecl:
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
70 auto structDecl = cast(StructDecl)decl;
158
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
71 if(printAtt) printAttribute(decl.att);
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
72 printBeginLine("struct ");
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
73 printIdentifier(structDecl.identifier);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
74 printEndLine;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
75 printOpenBrace;
102
cd066f3b539a Parsing methods in structs - error on semantics though.
Anders Johnsen <skabet@gmail.com>
parents: 101
diff changeset
76 foreach( var ; structDecl.decls)
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
77 printDecl(var);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
78 printCloseBrace;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
79 break;
101
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 94
diff changeset
80
144
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
81 case DeclType.ClassDecl:
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
82 auto classDecl = cast(ClassDecl)decl;
158
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
83 if(printAtt) printAttribute(decl.att);
144
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
84 printBeginLine("class ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
85 printIdentifier(classDecl.identifier);
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
86 foreach(i, iden ; classDecl.baseClasses )
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
87 {
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
88 print(i ? " : " : ", ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
89 printIdentifier(iden);
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
90 }
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
91 printEndLine;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
92 printOpenBrace;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
93 foreach( var ; classDecl.decls)
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
94 printDecl(var);
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
95 printCloseBrace;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
96 break;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
97
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
98 case DeclType.InterfaceDecl:
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
99 auto interfaceDecl = cast(InterfaceDecl)decl;
158
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
100 if(printAtt) printAttribute(decl.att);
144
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
101 printBeginLine("interface ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
102 printIdentifier(interfaceDecl.identifier);
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
103 foreach(i, iden ; interfaceDecl.baseClasses )
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
104 {
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
105 print(i ? " : " : ", ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
106 printIdentifier(iden);
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
107 }
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
108 printEndLine;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
109 printOpenBrace;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
110 foreach( var ; interfaceDecl.decls)
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
111 printDecl(var);
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
112 printCloseBrace;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
113 break;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
114
101
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 94
diff changeset
115 case DeclType.ImportDecl:
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 94
diff changeset
116 auto i = cast(ImportDecl)decl;
158
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
117 if(printAtt) printAttribute(decl.att);
101
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 94
diff changeset
118 printBeginLine("import ");
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 94
diff changeset
119 printEndLine(i.get);
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 94
diff changeset
120 break;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
121 }
144
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
122 // printEndLine();
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
123 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
124
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
125 void printStatement(Stmt stmt)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
126 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
127 switch(stmt.stmtType)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
128 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
129 case StmtType.Return:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
130 auto ret = cast(ReturnStmt)stmt;
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
131 printBeginLine("return");
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
132 if(ret.exp)
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
133 {
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
134 space;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
135 printExp(ret.exp);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
136 }
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
137 printEndLine(";");
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
138 break;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
139 case StmtType.Decl:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
140 auto declStmt = cast(DeclStmt)stmt;
158
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
141 printDecl(declStmt.decl, false);
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
142 break;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
143 case StmtType.Exp:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
144 auto expStmt = cast(ExpStmt)stmt;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
145 printBeginLine();
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
146 printExp(expStmt.exp);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
147 printEndLine(";");
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
148 break;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
149
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
150 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
151 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
152
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
153 void printExp(Exp exp)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
154 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
155 switch(exp.expType)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
156 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
157 case ExpType.Binary:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
158 auto binaryExp = cast(BinaryExp)exp;
68
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 63
diff changeset
159 print("(");
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
160 printExp(binaryExp.left);
68
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 63
diff changeset
161 print(" " ~ binaryExp.getOp[binaryExp.op] ~ " ");
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
162 printExp(binaryExp.right);
68
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 63
diff changeset
163 print(")");
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
164 break;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
165 case ExpType.IntegerLit:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
166 auto integetLit = cast(IntegerLit)exp;
88
eb5b2c719a39 Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents: 79
diff changeset
167 print(integetLit.get);
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
168 break;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
169 case ExpType.Negate:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
170 auto negateExp = cast(NegateExp)exp;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
171 print("-");
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
172 printExp(negateExp.exp);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
173 break;
78
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 68
diff changeset
174 case ExpType.Deref:
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 68
diff changeset
175 auto derefExp = cast(DerefExp)exp;
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 68
diff changeset
176 print("*");
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 68
diff changeset
177 printExp(derefExp.exp);
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 68
diff changeset
178 break;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
179 case ExpType.AssignExp:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
180 auto assignExp = cast(AssignExp)exp;
28
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 1
diff changeset
181 printExp(assignExp.identifier);
126
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents: 102
diff changeset
182 print(" ");
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents: 102
diff changeset
183 print(assignExp.getOp[assignExp.op]);
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents: 102
diff changeset
184 print(" ");
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
185 printExp(assignExp.exp);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
186 break;
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
187 case ExpType.MemberReference:
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
188 auto mrExp = cast(MemberReference)exp;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
189 printExp(mrExp.target);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
190 print(".");
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
191 printIdentifier(mrExp.child);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
192 break;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
193 case ExpType.Identifier:
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
194 auto iden = cast(Identifier)exp;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
195 printIdentifier(iden);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
196 break;
77
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
197 case ExpType.PointerIdentifier:
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
198 auto iden = cast(PointerIdentifier)exp;
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
199 printExp(iden.pointerOf);
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
200 print("*");
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
201 break;
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
202 case ExpType.CallExp:
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
203 auto callExp = cast(CallExp)exp;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
204 printExp(callExp.exp);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
205 print("(");
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
206 foreach(i, e; callExp.args)
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
207 {
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
208 printExp(e);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
209 if(i+1 < callExp.args.length)
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
210 print(", ");
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
211 }
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
212 print(")");
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
213 break;
68
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 63
diff changeset
214 case ExpType.CastExp:
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 63
diff changeset
215 auto castExp = cast(CastExp)exp;
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 63
diff changeset
216 print("cast");
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 63
diff changeset
217 print("(");
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 63
diff changeset
218 printExp(castExp.castType);
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 63
diff changeset
219 print(")");
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 63
diff changeset
220 printExp(castExp.exp);
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 63
diff changeset
221 break;
158
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
222 case ExpType.NewExp:
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
223 auto newExp = cast(NewExp)exp;
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
224 print("new ");
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
225 if(newExp.a_args.length)
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
226 {
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
227 foreach( i, a ; newExp.a_args )
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
228 {
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
229 print(i ? ", " : "(");
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
230 printExp(a);
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
231 }
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
232 print(")");
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
233 }
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
234 printExp(newExp.newType);
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
235 print("(");
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
236 foreach( i, c ; newExp.c_args )
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
237 {
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
238 print(i ? ", " : "");
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
239 printExp(c);
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
240 }
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
241 print(")");
57b0b4464a0b Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents: 148
diff changeset
242 break;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
243 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
244
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
245 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
246
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
247 void printFuncArgs(FuncDecl decl)
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
248 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
249 print("(");
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
250
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
251 foreach(i, d; decl.funcArgs)
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
252 {
63
9f8131676242 Now Decl's have a DType type(), and should use varType and returnType to get the old type id
Anders Halager <halager@gmail.com>
parents: 60
diff changeset
253 printIdentifier(d.varType);
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
254 if(i == 0 && decl.sret)
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
255 print("*");
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
256 space;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
257 printIdentifier(d.identifier);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
258 if(i+1 < decl.funcArgs.length)
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
259 print(",");
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
260 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
261
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
262 printEndLine(")");
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
263 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
264
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
265 void printIdentifier(Identifier identifier)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
266 {
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
267 print(identifier.get);
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
268 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
269
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
270 void printOpenBrace()
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
271 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
272 printEndLine(tabIndex~"{");
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
273 tabIndex ~= tabType;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
274 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
275
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
276 void printCloseBrace()
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
277 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
278 tabIndex = tabIndex[0 .. $-tabType.length];
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
279 printEndLine(tabIndex~"}");
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
280 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
281
144
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
282 void printAttribute(Attribute a)
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
283 {
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
284 switch(a.getExtern)
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
285 {
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
286 case Extern.C:
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
287 print("extern(C) ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
288 break;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
289 case Extern.CPlusPlus:
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
290 print("extern(C++) ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
291 break;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
292 case Extern.D:
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
293 break;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
294 }
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
295 switch(a.getProtection)
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
296 {
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
297 case Protection.Public:
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
298 print("public ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
299 break;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
300 case Protection.Private:
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
301 print("private ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
302 break;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
303 case Protection.Package:
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
304 print("package ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
305 break;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
306 case Protection.Protected:
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
307 print("protected ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
308 break;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
309 case Protection.Export:
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
310 print("export ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
311 break;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
312 }
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
313 if ( a.getStatic )
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
314 print("static ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
315 if ( a.getFinal )
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
316 print("final ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
317 if ( a.getConst )
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
318 print("const ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
319 if ( a.getAbstract )
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
320 print("abstract ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
321 if ( a.getOverride )
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
322 print("override ");
148
6ec686d9c87d Fixed some for parsing, and removed a little ugly bug.
Anders Johnsen <skabet@gmail.com>
parents: 144
diff changeset
323 if ( a.getDeprecated )
6ec686d9c87d Fixed some for parsing, and removed a little ugly bug.
Anders Johnsen <skabet@gmail.com>
parents: 144
diff changeset
324 print("deprecated ");
144
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
325 if ( a.getAuto )
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
326 print("auto ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
327 }
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
328
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
329 void printBeginLine(char[] line = "")
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
330 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
331 Stdout(tabIndex~line);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
332 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
333
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
334 void printEndLine(char[] line = "")
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
335 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
336 Stdout(line).newline;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
337 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
338
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
339 void print(char[] line)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
340 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
341 Stdout(line);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
342 }
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
343
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
344 void space()
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
345 {
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
346 print(" ");
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
347 }
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
348 private:
88
eb5b2c719a39 Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents: 79
diff changeset
349 SourceManager sm;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
350 char[] tabIndex;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
351 }