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