Mercurial > projects > dil
annotate trunk/src/Statements.d @ 264:50cc74026ea8
- Changed some string types to Token*.
author | aziz |
---|---|
date | Fri, 03 Aug 2007 17:51:02 +0000 |
parents | 966756c5d5d3 |
children | c19b68a4e3db |
rev | line source |
---|---|
102 | 1 /++ |
2 Author: Aziz Köksal | |
249 | 3 License: GPL3 |
102 | 4 +/ |
5 module Statements; | |
240
deab661906ae
- Classes Declaration, Expression, Statement and Type inherit from Node now.
aziz
parents:
238
diff
changeset
|
6 import SyntaxTree; |
162 | 7 import Expressions; |
185 | 8 import Declarations; |
162 | 9 import Types; |
169 | 10 import Token; |
102 | 11 |
240
deab661906ae
- Classes Declaration, Expression, Statement and Type inherit from Node now.
aziz
parents:
238
diff
changeset
|
12 class Statement : Node |
102 | 13 { |
240
deab661906ae
- Classes Declaration, Expression, Statement and Type inherit from Node now.
aziz
parents:
238
diff
changeset
|
14 this() |
deab661906ae
- Classes Declaration, Expression, Statement and Type inherit from Node now.
aziz
parents:
238
diff
changeset
|
15 { |
deab661906ae
- Classes Declaration, Expression, Statement and Type inherit from Node now.
aziz
parents:
238
diff
changeset
|
16 super(NodeType.Expression); |
deab661906ae
- Classes Declaration, Expression, Statement and Type inherit from Node now.
aziz
parents:
238
diff
changeset
|
17 } |
102 | 18 } |
161 | 19 |
20 class Statements : Statement | |
21 { | |
22 Statement[] ss; | |
23 void opCatAssign(Statement s) | |
24 { | |
25 this.ss ~= s; | |
26 } | |
27 } | |
28 | |
206 | 29 class IllegalStatement : Statement |
30 { | |
250 | 31 Token* tok; |
32 this(Token* tok) | |
206 | 33 { |
34 this.tok = tok; | |
35 } | |
36 } | |
37 | |
216 | 38 class EmptyStatement : Statement |
39 { | |
40 this() | |
41 { | |
42 } | |
43 } | |
44 | |
192 | 45 class FunctionBody |
46 { | |
47 Statement funcBody, inBody, outBody; | |
264 | 48 Token* outIdent; |
192 | 49 } |
50 | |
162 | 51 class ScopeStatement : Statement |
52 { | |
53 Statement s; | |
54 this(Statement s) | |
55 { | |
56 this.s = s; | |
57 } | |
58 } | |
59 | |
161 | 60 class LabeledStatement : Statement |
61 { | |
264 | 62 Token* label; |
161 | 63 Statement s; |
264 | 64 this(Token* label, Statement s) |
161 | 65 { |
66 this.label = label; | |
67 this.s = s; | |
68 } | |
69 } | |
70 | |
71 class ExpressionStatement : Statement | |
72 { | |
187 | 73 Expression expression; |
74 this(Expression expression) | |
75 { | |
76 this.expression = expression; | |
77 } | |
161 | 78 } |
79 | |
80 class DeclarationStatement : Statement | |
81 { | |
188 | 82 Declaration declaration; |
83 this(Declaration declaration) | |
84 { | |
85 this.declaration = declaration; | |
86 } | |
161 | 87 } |
88 | |
89 class IfStatement : Statement | |
90 { | |
162 | 91 Type type; |
253
4279b638c63e
- Changed some string types to Token*. Adapted parser accordingly.
aziz
parents:
250
diff
changeset
|
92 Token* ident; |
162 | 93 Expression condition; |
94 Statement ifBody; | |
95 Statement elseBody; | |
253
4279b638c63e
- Changed some string types to Token*. Adapted parser accordingly.
aziz
parents:
250
diff
changeset
|
96 this(Type type, Token* ident, Expression condition, Statement ifBody, Statement elseBody) |
162 | 97 { |
98 this.type = type; | |
99 this.ident = ident; | |
100 this.condition = condition; | |
101 this.ifBody = ifBody; | |
102 this.elseBody = elseBody; | |
103 } | |
161 | 104 } |
261 | 105 /+ |
161 | 106 class ConditionalStatement : Statement |
107 { | |
108 | |
109 } | |
261 | 110 +/ |
161 | 111 class WhileStatement : Statement |
112 { | |
164 | 113 Expression condition; |
114 Statement whileBody; | |
115 this(Expression condition, Statement whileBody) | |
116 { | |
117 this.condition = condition; | |
118 this.whileBody = whileBody; | |
119 } | |
161 | 120 } |
121 | |
165 | 122 class DoWhileStatement : Statement |
161 | 123 { |
165 | 124 Expression condition; |
125 Statement doBody; | |
126 this(Expression condition, Statement doBody) | |
127 { | |
128 this.condition = condition; | |
129 this.doBody = doBody; | |
130 } | |
161 | 131 } |
132 | |
133 class ForStatement : Statement | |
134 { | |
166 | 135 Statement init; |
136 Expression condition, increment; | |
137 Statement forBody; | |
169 | 138 |
166 | 139 this(Statement init, Expression condition, Expression increment, Statement forBody) |
140 { | |
141 this.init = init; | |
142 this.condition = condition; | |
143 this.increment = increment; | |
144 this.forBody = forBody; | |
145 } | |
161 | 146 } |
147 | |
148 class ForeachStatement : Statement | |
149 { | |
169 | 150 TOK tok; |
151 Parameters params; | |
152 Expression aggregate; | |
153 Statement forBody; | |
161 | 154 |
169 | 155 this(TOK tok, Parameters params, Expression aggregate, Statement forBody) |
156 { | |
157 this.tok = tok; | |
158 this.params = params; | |
159 this.aggregate = aggregate; | |
160 this.forBody = forBody; | |
161 } | |
161 | 162 } |
163 | |
164 class SwitchStatement : Statement | |
165 { | |
170 | 166 Expression condition; |
167 Statement switchBody; | |
161 | 168 |
170 | 169 this(Expression condition, Statement switchBody) |
170 { | |
171 this.condition = condition; | |
172 this.switchBody = switchBody; | |
173 } | |
161 | 174 } |
175 | |
176 class CaseStatement : Statement | |
177 { | |
171 | 178 Expression[] values; |
179 Statement caseBody; | |
161 | 180 |
171 | 181 this(Expression[] values, Statement caseBody) |
182 { | |
183 this.values = values; | |
184 this.caseBody = caseBody; | |
185 } | |
161 | 186 } |
187 | |
188 class DefaultStatement : Statement | |
189 { | |
172 | 190 Statement defaultBody; |
191 this(Statement defaultBody) | |
192 { | |
193 this.defaultBody = defaultBody; | |
194 } | |
161 | 195 } |
196 | |
197 class ContinueStatement : Statement | |
198 { | |
264 | 199 Token* ident; |
200 this(Token* ident) | |
173 | 201 { |
202 this.ident = ident; | |
203 } | |
161 | 204 } |
205 | |
206 class BreakStatement : Statement | |
207 { | |
264 | 208 Token* ident; |
209 this(Token* ident) | |
174 | 210 { |
211 this.ident = ident; | |
212 } | |
161 | 213 } |
214 | |
215 class ReturnStatement : Statement | |
216 { | |
175 | 217 Expression expr; |
218 this(Expression expr) | |
219 { | |
220 this.expr = expr; | |
221 } | |
161 | 222 } |
223 | |
224 class GotoStatement : Statement | |
225 { | |
264 | 226 Token* ident; |
176 | 227 Expression caseExpr; |
264 | 228 this(Token* ident, Expression caseExpr) |
176 | 229 { |
230 this.ident = ident; | |
231 this.caseExpr = caseExpr; | |
232 } | |
161 | 233 } |
234 | |
235 class WithStatement : Statement | |
236 { | |
177 | 237 Expression expr; |
238 Statement withBody; | |
239 this(Expression expr, Statement withBody) | |
240 { | |
241 this.expr = expr; | |
242 this.withBody = withBody; | |
243 } | |
161 | 244 } |
245 | |
246 class SynchronizedStatement : Statement | |
247 { | |
178 | 248 Expression expr; |
249 Statement syncBody; | |
250 this(Expression expr, Statement withBody) | |
251 { | |
252 this.expr = expr; | |
253 this.syncBody = syncBody; | |
254 } | |
161 | 255 } |
256 | |
257 class TryStatement : Statement | |
258 { | |
179 | 259 Statement tryBody; |
260 CatchBody[] catchBodies; | |
261 FinallyBody finallyBody; | |
262 this(Statement tryBody, CatchBody[] catchBodies, FinallyBody finallyBody) | |
263 { | |
264 this.tryBody = tryBody; | |
265 this.catchBodies = catchBodies; | |
266 this.finallyBody = finallyBody; | |
267 } | |
268 } | |
161 | 269 |
179 | 270 class CatchBody : Statement |
271 { | |
272 Parameter param; | |
273 Statement catchBody; | |
274 this(Parameter param, Statement catchBody) | |
275 { | |
276 this.param = param; | |
277 this.catchBody = catchBody; | |
278 } | |
279 } | |
280 | |
281 class FinallyBody : Statement | |
282 { | |
283 Statement finallyBody; | |
284 this(Statement finallyBody) | |
285 { | |
286 this.finallyBody = finallyBody; | |
287 } | |
161 | 288 } |
289 | |
290 class ScopeGuardStatement : Statement | |
291 { | |
264 | 292 Token* condition; |
181 | 293 Statement scopeBody; |
264 | 294 this(Token* condition, Statement scopeBody) |
181 | 295 { |
296 this.condition = condition; | |
297 this.scopeBody = scopeBody; | |
298 } | |
161 | 299 } |
300 | |
301 class ThrowStatement : Statement | |
302 { | |
180 | 303 Expression expr; |
304 this(Expression expr) | |
305 { | |
306 this.expr = expr; | |
307 } | |
161 | 308 } |
309 | |
310 class VolatileStatement : Statement | |
311 { | |
182 | 312 Statement volatileBody; |
313 this(Statement volatileBody) | |
314 { | |
315 this.volatileBody = volatileBody; | |
316 } | |
161 | 317 } |
318 | |
319 class AsmStatement : Statement | |
320 { | |
321 | |
322 } | |
323 | |
324 class PragmaStatement : Statement | |
325 { | |
245 | 326 Token* ident; |
184 | 327 Expression[] args; |
328 Statement pragmaBody; | |
245 | 329 this(Token* ident, Expression[] args, Statement pragmaBody) |
184 | 330 { |
331 this.ident = ident; | |
332 this.args = args; | |
333 this.pragmaBody = pragmaBody; | |
334 } | |
161 | 335 } |
336 | |
337 class MixinStatement : Statement | |
338 { | |
256 | 339 Expression[] templateIdent; |
340 Token* mixinIdent; | |
341 this(Expression[] templateIdent, Token* mixinIdent) | |
185 | 342 { |
256 | 343 this.templateIdent = templateIdent; |
344 this.mixinIdent = mixinIdent; | |
185 | 345 } |
161 | 346 } |
186
d4292a5a7b8b
- Implemented parseStaticIfStatement() and parseStaticAssertStatement().
aziz
parents:
185
diff
changeset
|
347 |
d4292a5a7b8b
- Implemented parseStaticIfStatement() and parseStaticAssertStatement().
aziz
parents:
185
diff
changeset
|
348 class StaticIfStatement : Statement |
d4292a5a7b8b
- Implemented parseStaticIfStatement() and parseStaticAssertStatement().
aziz
parents:
185
diff
changeset
|
349 { |
d4292a5a7b8b
- Implemented parseStaticIfStatement() and parseStaticAssertStatement().
aziz
parents:
185
diff
changeset
|
350 Expression condition; |
d4292a5a7b8b
- Implemented parseStaticIfStatement() and parseStaticAssertStatement().
aziz
parents:
185
diff
changeset
|
351 Statement ifBody, elseBody; |
d4292a5a7b8b
- Implemented parseStaticIfStatement() and parseStaticAssertStatement().
aziz
parents:
185
diff
changeset
|
352 this(Expression condition, Statement ifBody, Statement elseBody) |
d4292a5a7b8b
- Implemented parseStaticIfStatement() and parseStaticAssertStatement().
aziz
parents:
185
diff
changeset
|
353 { |
d4292a5a7b8b
- Implemented parseStaticIfStatement() and parseStaticAssertStatement().
aziz
parents:
185
diff
changeset
|
354 this.condition = condition; |
d4292a5a7b8b
- Implemented parseStaticIfStatement() and parseStaticAssertStatement().
aziz
parents:
185
diff
changeset
|
355 this.ifBody = ifBody; |
d4292a5a7b8b
- Implemented parseStaticIfStatement() and parseStaticAssertStatement().
aziz
parents:
185
diff
changeset
|
356 this.elseBody = elseBody; |
d4292a5a7b8b
- Implemented parseStaticIfStatement() and parseStaticAssertStatement().
aziz
parents:
185
diff
changeset
|
357 } |
d4292a5a7b8b
- Implemented parseStaticIfStatement() and parseStaticAssertStatement().
aziz
parents:
185
diff
changeset
|
358 } |
d4292a5a7b8b
- Implemented parseStaticIfStatement() and parseStaticAssertStatement().
aziz
parents:
185
diff
changeset
|
359 |
d4292a5a7b8b
- Implemented parseStaticIfStatement() and parseStaticAssertStatement().
aziz
parents:
185
diff
changeset
|
360 class StaticAssertStatement : Statement |
d4292a5a7b8b
- Implemented parseStaticIfStatement() and parseStaticAssertStatement().
aziz
parents:
185
diff
changeset
|
361 { |
d4292a5a7b8b
- Implemented parseStaticIfStatement() and parseStaticAssertStatement().
aziz
parents:
185
diff
changeset
|
362 Expression condition, message; |
d4292a5a7b8b
- Implemented parseStaticIfStatement() and parseStaticAssertStatement().
aziz
parents:
185
diff
changeset
|
363 this(Expression condition, Expression message) |
d4292a5a7b8b
- Implemented parseStaticIfStatement() and parseStaticAssertStatement().
aziz
parents:
185
diff
changeset
|
364 { |
d4292a5a7b8b
- Implemented parseStaticIfStatement() and parseStaticAssertStatement().
aziz
parents:
185
diff
changeset
|
365 this.condition = condition; |
d4292a5a7b8b
- Implemented parseStaticIfStatement() and parseStaticAssertStatement().
aziz
parents:
185
diff
changeset
|
366 this.message = message; |
d4292a5a7b8b
- Implemented parseStaticIfStatement() and parseStaticAssertStatement().
aziz
parents:
185
diff
changeset
|
367 } |
187 | 368 } |
190
d0712601fa47
- Implemented parseDebugStatement() and parseVersionStatement().
aziz
parents:
188
diff
changeset
|
369 |
d0712601fa47
- Implemented parseDebugStatement() and parseVersionStatement().
aziz
parents:
188
diff
changeset
|
370 class DebugStatement : Statement |
d0712601fa47
- Implemented parseDebugStatement() and parseVersionStatement().
aziz
parents:
188
diff
changeset
|
371 { |
264 | 372 Token* cond; |
190
d0712601fa47
- Implemented parseDebugStatement() and parseVersionStatement().
aziz
parents:
188
diff
changeset
|
373 Statement debugBody, elseBody; |
264 | 374 this(Token* cond, Statement debugBody, Statement elseBody) |
190
d0712601fa47
- Implemented parseDebugStatement() and parseVersionStatement().
aziz
parents:
188
diff
changeset
|
375 { |
264 | 376 this.cond = cond; |
190
d0712601fa47
- Implemented parseDebugStatement() and parseVersionStatement().
aziz
parents:
188
diff
changeset
|
377 this.debugBody = debugBody; |
d0712601fa47
- Implemented parseDebugStatement() and parseVersionStatement().
aziz
parents:
188
diff
changeset
|
378 this.elseBody = elseBody; |
d0712601fa47
- Implemented parseDebugStatement() and parseVersionStatement().
aziz
parents:
188
diff
changeset
|
379 } |
d0712601fa47
- Implemented parseDebugStatement() and parseVersionStatement().
aziz
parents:
188
diff
changeset
|
380 } |
d0712601fa47
- Implemented parseDebugStatement() and parseVersionStatement().
aziz
parents:
188
diff
changeset
|
381 |
d0712601fa47
- Implemented parseDebugStatement() and parseVersionStatement().
aziz
parents:
188
diff
changeset
|
382 class VersionStatement : Statement |
d0712601fa47
- Implemented parseDebugStatement() and parseVersionStatement().
aziz
parents:
188
diff
changeset
|
383 { |
264 | 384 Token* cond; |
190
d0712601fa47
- Implemented parseDebugStatement() and parseVersionStatement().
aziz
parents:
188
diff
changeset
|
385 Statement versionBody, elseBody; |
264 | 386 this(Token* cond, Statement versionBody, Statement elseBody) |
190
d0712601fa47
- Implemented parseDebugStatement() and parseVersionStatement().
aziz
parents:
188
diff
changeset
|
387 { |
264 | 388 this.cond = cond; |
190
d0712601fa47
- Implemented parseDebugStatement() and parseVersionStatement().
aziz
parents:
188
diff
changeset
|
389 this.versionBody = versionBody; |
d0712601fa47
- Implemented parseDebugStatement() and parseVersionStatement().
aziz
parents:
188
diff
changeset
|
390 this.elseBody = elseBody; |
d0712601fa47
- Implemented parseDebugStatement() and parseVersionStatement().
aziz
parents:
188
diff
changeset
|
391 } |
d0712601fa47
- Implemented parseDebugStatement() and parseVersionStatement().
aziz
parents:
188
diff
changeset
|
392 } |
201 | 393 |
394 class AttributeStatement : Statement | |
395 { | |
396 TOK tok; | |
397 Statement statement; | |
398 this(TOK tok, Statement statement) | |
399 { | |
400 this.tok = tok; | |
401 this.statement = statement; | |
402 } | |
403 } | |
238
f3c6c15961bb
- Added method peekNext(). Replaced code that used lx.peek() with peekNext().
aziz
parents:
216
diff
changeset
|
404 |
f3c6c15961bb
- Added method peekNext(). Replaced code that used lx.peek() with peekNext().
aziz
parents:
216
diff
changeset
|
405 class ExternStatement : AttributeStatement |
f3c6c15961bb
- Added method peekNext(). Replaced code that used lx.peek() with peekNext().
aziz
parents:
216
diff
changeset
|
406 { |
f3c6c15961bb
- Added method peekNext(). Replaced code that used lx.peek() with peekNext().
aziz
parents:
216
diff
changeset
|
407 Linkage linkage; |
f3c6c15961bb
- Added method peekNext(). Replaced code that used lx.peek() with peekNext().
aziz
parents:
216
diff
changeset
|
408 this(Linkage linkage, Statement statement) |
f3c6c15961bb
- Added method peekNext(). Replaced code that used lx.peek() with peekNext().
aziz
parents:
216
diff
changeset
|
409 { |
f3c6c15961bb
- Added method peekNext(). Replaced code that used lx.peek() with peekNext().
aziz
parents:
216
diff
changeset
|
410 super(TOK.Extern, statement); |
f3c6c15961bb
- Added method peekNext(). Replaced code that used lx.peek() with peekNext().
aziz
parents:
216
diff
changeset
|
411 this.linkage = linkage; |
f3c6c15961bb
- Added method peekNext(). Replaced code that used lx.peek() with peekNext().
aziz
parents:
216
diff
changeset
|
412 } |
f3c6c15961bb
- Added method peekNext(). Replaced code that used lx.peek() with peekNext().
aziz
parents:
216
diff
changeset
|
413 } |