Mercurial > projects > dang
annotate tools/AstPrinter.d @ 101:fea8d61a2451 new_gen
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...?)
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Wed, 07 May 2008 19:58:13 +0200 |
parents | 48bb2287c035 |
children | cd066f3b539a |
rev | line source |
---|---|
1 | 1 module tools.AstPrinter; |
2 | |
3 import tango.io.Stdout; | |
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 | 7 ast.Stmt, |
8 ast.Exp; | |
9 | |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
79
diff
changeset
|
10 import basic.SourceManager; |
1 | 11 |
12 class AstPrinter | |
13 { | |
14 const char[] tabType = " "; // 4 spaces | |
15 | |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
79
diff
changeset
|
16 this(SourceManager sm) |
1 | 17 { |
18 | |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
79
diff
changeset
|
19 this.sm = sm; |
1 | 20 } |
21 | |
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
|
22 void print(Module m) |
1 | 23 { |
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
|
24 printBeginLine("module "); |
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 printEndLine(m.moduleName); |
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
|
26 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
|
27 foreach(decl ; m.decls) |
1 | 28 { |
29 printDecl(decl); | |
30 } | |
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
|
31 printEndLine(); |
1 | 32 } |
33 | |
34 void printDecl(Decl decl) | |
35 { | |
36 switch(decl.declType) | |
37 { | |
38 case DeclType.FuncDecl: | |
39 auto funcDecl = cast(FuncDecl)decl; | |
40 printBeginLine(); | |
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
|
41 printIdentifier(funcDecl.returnType); |
60
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
42 space; |
1 | 43 printIdentifier(funcDecl.identifier); |
60
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
44 printFuncArgs(funcDecl); |
1 | 45 printOpenBrace(); |
46 foreach(stmt ; funcDecl.statements) | |
47 printStatement(stmt); | |
48 printCloseBrace(); | |
49 break; | |
50 | |
51 case DeclType.VarDecl: | |
52 auto varDecl = cast(VarDecl)decl; | |
53 printBeginLine(); | |
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
|
54 printExp(varDecl.varType); |
60
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
55 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
|
56 printExp(varDecl.identifier); |
1 | 57 if(varDecl.init) |
58 { | |
60
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
59 print(" = "); |
1 | 60 printExp(varDecl.init); |
61 } | |
62 printEndLine(";"); | |
63 break; | |
60
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
64 |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
65 case DeclType.StructDecl: |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
66 auto structDecl = cast(StructDecl)decl; |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
67 printBeginLine("struct "); |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
68 printIdentifier(structDecl.identifier); |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
69 printEndLine; |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
70 printOpenBrace; |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
71 foreach( var ; structDecl.vars) |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
72 printDecl(var); |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
73 printCloseBrace; |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
74 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
|
75 |
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
|
76 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
|
77 auto i = cast(ImportDecl)decl; |
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
|
78 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
|
79 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
|
80 break; |
1 | 81 } |
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
|
82 printEndLine(); |
1 | 83 } |
84 | |
85 void printStatement(Stmt stmt) | |
86 { | |
87 switch(stmt.stmtType) | |
88 { | |
89 case StmtType.Return: | |
90 auto ret = cast(ReturnStmt)stmt; | |
60
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
91 printBeginLine("return"); |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
92 if(ret.exp) |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
93 { |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
94 space; |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
95 printExp(ret.exp); |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
96 } |
1 | 97 printEndLine(";"); |
98 break; | |
99 case StmtType.Decl: | |
100 auto declStmt = cast(DeclStmt)stmt; | |
101 printDecl(declStmt.decl); | |
102 break; | |
103 case StmtType.Exp: | |
104 auto expStmt = cast(ExpStmt)stmt; | |
105 printBeginLine(); | |
106 printExp(expStmt.exp); | |
107 printEndLine(";"); | |
108 break; | |
109 | |
110 } | |
111 } | |
112 | |
113 void printExp(Exp exp) | |
114 { | |
115 switch(exp.expType) | |
116 { | |
117 case ExpType.Binary: | |
118 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
|
119 print("("); |
1 | 120 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
|
121 print(" " ~ binaryExp.getOp[binaryExp.op] ~ " "); |
1 | 122 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
|
123 print(")"); |
1 | 124 break; |
125 case ExpType.IntegerLit: | |
126 auto integetLit = cast(IntegerLit)exp; | |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
79
diff
changeset
|
127 print(integetLit.get); |
1 | 128 break; |
129 case ExpType.Negate: | |
130 auto negateExp = cast(NegateExp)exp; | |
131 print("-"); | |
132 printExp(negateExp.exp); | |
133 break; | |
78
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
134 case ExpType.Deref: |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
135 auto derefExp = cast(DerefExp)exp; |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
136 print("*"); |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
137 printExp(derefExp.exp); |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
138 break; |
1 | 139 case ExpType.AssignExp: |
140 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
|
141 printExp(assignExp.identifier); |
60
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
142 print(" = "); |
1 | 143 printExp(assignExp.exp); |
144 break; | |
60
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
145 case ExpType.MemberReference: |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
146 auto mrExp = cast(MemberReference)exp; |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
147 printExp(mrExp.target); |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
148 print("."); |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
149 printIdentifier(mrExp.child); |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
150 break; |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
151 case ExpType.Identifier: |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
152 auto iden = cast(Identifier)exp; |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
153 printIdentifier(iden); |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
154 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
|
155 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
|
156 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
|
157 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
|
158 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
|
159 break; |
60
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
160 case ExpType.CallExp: |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
161 auto callExp = cast(CallExp)exp; |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
162 printExp(callExp.exp); |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
163 print("("); |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
164 foreach(i, e; callExp.args) |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
165 { |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
166 printExp(e); |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
167 if(i+1 < callExp.args.length) |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
168 print(", "); |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
169 } |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
170 print(")"); |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
171 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
|
172 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
|
173 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
|
174 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
|
175 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
|
176 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
|
177 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
|
178 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
|
179 break; |
1 | 180 } |
181 | |
182 } | |
183 | |
60
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
184 void printFuncArgs(FuncDecl decl) |
1 | 185 { |
186 print("("); | |
187 | |
60
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
188 foreach(i, d; decl.funcArgs) |
1 | 189 { |
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
|
190 printIdentifier(d.varType); |
60
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
191 if(i == 0 && decl.sret) |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
192 print("*"); |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
193 space; |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
194 printIdentifier(d.identifier); |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
195 if(i+1 < decl.funcArgs.length) |
1 | 196 print(","); |
197 } | |
198 | |
199 printEndLine(")"); | |
200 } | |
201 | |
202 void printIdentifier(Identifier identifier) | |
203 { | |
60
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
204 print(identifier.get); |
1 | 205 } |
206 | |
207 void printOpenBrace() | |
208 { | |
209 printEndLine(tabIndex~"{"); | |
210 tabIndex ~= tabType; | |
211 } | |
212 | |
213 void printCloseBrace() | |
214 { | |
215 tabIndex = tabIndex[0 .. $-tabType.length]; | |
216 printEndLine(tabIndex~"}"); | |
217 } | |
218 | |
219 void printBeginLine(char[] line = "") | |
220 { | |
221 Stdout(tabIndex~line); | |
222 } | |
223 | |
224 void printEndLine(char[] line = "") | |
225 { | |
226 Stdout(line).newline; | |
227 } | |
228 | |
229 void print(char[] line) | |
230 { | |
231 Stdout(line); | |
232 } | |
60
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
233 |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
234 void space() |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
235 { |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
236 print(" "); |
2451f0904bf6
Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents:
28
diff
changeset
|
237 } |
1 | 238 private: |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
79
diff
changeset
|
239 SourceManager sm; |
1 | 240 char[] tabIndex; |
241 } |