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