annotate tools/AstPrinter.d @ 163:362265427838

Fixes to types for constructor and also removed DFunction's from DStruct, DClass and DInterface
author Anders Johnsen <skabet@gmail.com>
date Tue, 22 Jul 2008 16:50:47 +0200
parents 57b0b4464a0b
children 01c2c49775ef
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();
163
362265427838 Fixes to types for constructor and also removed DFunction's from DStruct, DClass and DInterface
Anders Johnsen <skabet@gmail.com>
parents: 158
diff changeset
43 if (printAtt) printAttribute(decl.att);
362265427838 Fixes to types for constructor and also removed DFunction's from DStruct, DClass and DInterface
Anders Johnsen <skabet@gmail.com>
parents: 158
diff changeset
44 if (funcDecl.identifier.get != "this")
362265427838 Fixes to types for constructor and also removed DFunction's from DStruct, DClass and DInterface
Anders Johnsen <skabet@gmail.com>
parents: 158
diff changeset
45 {
362265427838 Fixes to types for constructor and also removed DFunction's from DStruct, DClass and DInterface
Anders Johnsen <skabet@gmail.com>
parents: 158
diff changeset
46 printIdentifier(funcDecl.returnType);
362265427838 Fixes to types for constructor and also removed DFunction's from DStruct, DClass and DInterface
Anders Johnsen <skabet@gmail.com>
parents: 158
diff changeset
47 space;
362265427838 Fixes to types for constructor and also removed DFunction's from DStruct, DClass and DInterface
Anders Johnsen <skabet@gmail.com>
parents: 158
diff changeset
48 }
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
49 printIdentifier(funcDecl.identifier);
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
50 printFuncArgs(funcDecl);
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
51 printOpenBrace();
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
52 foreach(stmt ; funcDecl.statements)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
53 printStatement(stmt);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
54 printCloseBrace();
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
55 break;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
56
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
57 case DeclType.VarDecl:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
58 auto varDecl = cast(VarDecl)decl;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
59 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
60 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
61 printExp(varDecl.varType);
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
62 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
63 printExp(varDecl.identifier);
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
64 if(varDecl.init)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
65 {
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
66 print(" = ");
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
67 printExp(varDecl.init);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
68 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
69 printEndLine(";");
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
70 break;
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
71
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
72 case DeclType.StructDecl:
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
73 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
74 if(printAtt) printAttribute(decl.att);
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
75 printBeginLine("struct ");
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
76 printIdentifier(structDecl.identifier);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
77 printEndLine;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
78 printOpenBrace;
102
cd066f3b539a Parsing methods in structs - error on semantics though.
Anders Johnsen <skabet@gmail.com>
parents: 101
diff changeset
79 foreach( var ; structDecl.decls)
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
80 printDecl(var);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
81 printCloseBrace;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
82 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
83
144
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
84 case DeclType.ClassDecl:
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
85 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
86 if(printAtt) printAttribute(decl.att);
144
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
87 printBeginLine("class ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
88 printIdentifier(classDecl.identifier);
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
89 foreach(i, iden ; classDecl.baseClasses )
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 print(i ? " : " : ", ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
92 printIdentifier(iden);
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
93 }
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
94 printEndLine;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
95 printOpenBrace;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
96 foreach( var ; classDecl.decls)
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
97 printDecl(var);
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
98 printCloseBrace;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
99 break;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
100
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
101 case DeclType.InterfaceDecl:
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
102 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
103 if(printAtt) printAttribute(decl.att);
144
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
104 printBeginLine("interface ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
105 printIdentifier(interfaceDecl.identifier);
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
106 foreach(i, iden ; interfaceDecl.baseClasses )
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 print(i ? " : " : ", ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
109 printIdentifier(iden);
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
110 }
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
111 printEndLine;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
112 printOpenBrace;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
113 foreach( var ; interfaceDecl.decls)
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
114 printDecl(var);
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
115 printCloseBrace;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
116 break;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
117
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 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
119 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
120 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
121 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
122 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
123 break;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
124 }
144
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
125 // printEndLine();
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
126 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
127
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
128 void printStatement(Stmt stmt)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
129 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
130 switch(stmt.stmtType)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
131 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
132 case StmtType.Return:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
133 auto ret = cast(ReturnStmt)stmt;
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
134 printBeginLine("return");
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
135 if(ret.exp)
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
136 {
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
137 space;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
138 printExp(ret.exp);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
139 }
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
140 printEndLine(";");
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
141 break;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
142 case StmtType.Decl:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
143 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
144 printDecl(declStmt.decl, false);
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
145 break;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
146 case StmtType.Exp:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
147 auto expStmt = cast(ExpStmt)stmt;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
148 printBeginLine();
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
149 printExp(expStmt.exp);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
150 printEndLine(";");
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
151 break;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
152
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
153 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
154 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
155
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
156 void printExp(Exp exp)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
157 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
158 switch(exp.expType)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
159 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
160 case ExpType.Binary:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
161 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
162 print("(");
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
163 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
164 print(" " ~ binaryExp.getOp[binaryExp.op] ~ " ");
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
165 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
166 print(")");
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
167 break;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
168 case ExpType.IntegerLit:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
169 auto integetLit = cast(IntegerLit)exp;
88
eb5b2c719a39 Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents: 79
diff changeset
170 print(integetLit.get);
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
171 break;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
172 case ExpType.Negate:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
173 auto negateExp = cast(NegateExp)exp;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
174 print("-");
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
175 printExp(negateExp.exp);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
176 break;
78
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 68
diff changeset
177 case ExpType.Deref:
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 68
diff changeset
178 auto derefExp = cast(DerefExp)exp;
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 68
diff changeset
179 print("*");
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 68
diff changeset
180 printExp(derefExp.exp);
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 68
diff changeset
181 break;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
182 case ExpType.AssignExp:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
183 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
184 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
185 print(" ");
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents: 102
diff changeset
186 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
187 print(" ");
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
188 printExp(assignExp.exp);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
189 break;
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
190 case ExpType.MemberReference:
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
191 auto mrExp = cast(MemberReference)exp;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
192 printExp(mrExp.target);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
193 print(".");
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
194 printIdentifier(mrExp.child);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
195 break;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
196 case ExpType.Identifier:
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
197 auto iden = cast(Identifier)exp;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
198 printIdentifier(iden);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
199 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
200 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
201 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
202 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
203 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
204 break;
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
205 case ExpType.CallExp:
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
206 auto callExp = cast(CallExp)exp;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
207 printExp(callExp.exp);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
208 print("(");
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
209 foreach(i, e; callExp.args)
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
210 {
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
211 printExp(e);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
212 if(i+1 < callExp.args.length)
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
213 print(", ");
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
214 }
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
215 print(")");
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
216 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
217 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
218 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
219 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
220 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
221 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
222 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
223 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
224 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
225 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
226 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
227 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
228 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
229 {
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 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
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(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
233 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
234 }
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 }
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 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
238 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
239 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
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(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
242 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
243 }
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
244 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
245 break;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
246 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
247
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
248 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
249
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
250 void printFuncArgs(FuncDecl decl)
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
251 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
252 print("(");
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
253
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
254 foreach(i, d; decl.funcArgs)
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
255 {
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
256 printIdentifier(d.varType);
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
257 if(i == 0 && decl.sret)
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
258 print("*");
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
259 space;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
260 printIdentifier(d.identifier);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
261 if(i+1 < decl.funcArgs.length)
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
262 print(",");
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 printEndLine(")");
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
266 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
267
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
268 void printIdentifier(Identifier identifier)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
269 {
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
270 print(identifier.get);
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
271 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
272
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
273 void printOpenBrace()
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
274 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
275 printEndLine(tabIndex~"{");
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
276 tabIndex ~= tabType;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
277 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
278
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
279 void printCloseBrace()
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
280 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
281 tabIndex = tabIndex[0 .. $-tabType.length];
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
282 printEndLine(tabIndex~"}");
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
283 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
284
144
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
285 void printAttribute(Attribute a)
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
286 {
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
287 switch(a.getExtern)
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
288 {
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
289 case Extern.C:
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.CPlusPlus:
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
293 print("extern(C++) ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
294 break;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
295 case Extern.D:
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
296 break;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
297 }
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
298 switch(a.getProtection)
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
299 {
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
300 case Protection.Public:
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
301 print("public ");
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.Private:
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
304 print("private ");
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.Package:
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
307 print("package ");
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.Protected:
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
310 print("protected ");
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 case Protection.Export:
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
313 print("export ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
314 break;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
315 }
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
316 if ( a.getStatic )
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
317 print("static ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
318 if ( a.getFinal )
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
319 print("final ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
320 if ( a.getConst )
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
321 print("const ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
322 if ( a.getAbstract )
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
323 print("abstract ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
324 if ( a.getOverride )
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
325 print("override ");
148
6ec686d9c87d Fixed some for parsing, and removed a little ugly bug.
Anders Johnsen <skabet@gmail.com>
parents: 144
diff changeset
326 if ( a.getDeprecated )
6ec686d9c87d Fixed some for parsing, and removed a little ugly bug.
Anders Johnsen <skabet@gmail.com>
parents: 144
diff changeset
327 print("deprecated ");
144
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
328 if ( a.getAuto )
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
329 print("auto ");
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
330 }
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 126
diff changeset
331
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
332 void printBeginLine(char[] line = "")
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
333 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
334 Stdout(tabIndex~line);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
335 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
336
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
337 void printEndLine(char[] line = "")
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
338 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
339 Stdout(line).newline;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
340 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
341
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
342 void print(char[] line)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
343 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
344 Stdout(line);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
345 }
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
346
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
347 void space()
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
348 {
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
349 print(" ");
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
350 }
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
351 private:
88
eb5b2c719a39 Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents: 79
diff changeset
352 SourceManager sm;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
353 char[] tabIndex;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
354 }