comparison trunk/src/dil/Statements.d @ 505:3bb94ba21490

Refactored a great amount of code. Changed many declaration types from Token* to Identifier*. Fix in parseStructInitializer(): append null to idents in else body. Fixed class Parameter and parseParameterList().
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Wed, 12 Dec 2007 02:25:42 +0100
parents 5a607597dc22
children c4bb948e5cc1
comparison
equal deleted inserted replaced
504:9076c4cea2a4 505:3bb94ba21490
6 import dil.SyntaxTree; 6 import dil.SyntaxTree;
7 import dil.Expressions; 7 import dil.Expressions;
8 import dil.Declarations; 8 import dil.Declarations;
9 import dil.Types; 9 import dil.Types;
10 import dil.Token; 10 import dil.Token;
11 import dil.Identifier;
11 12
12 abstract class Statement : Node 13 abstract class Statement : Node
13 { 14 {
14 this() 15 this()
15 { 16 {
47 } 48 }
48 49
49 class FunctionBody : Node 50 class FunctionBody : Node
50 { 51 {
51 Statement funcBody, inBody, outBody; 52 Statement funcBody, inBody, outBody;
52 Token* outIdent; 53 Identifier* outIdent;
53 this() 54 this()
54 { 55 {
55 super(NodeCategory.Other); 56 super(NodeCategory.Other);
56 mixin(set_kind); 57 mixin(set_kind);
57 } 58 }
75 } 76 }
76 } 77 }
77 78
78 class LabeledStatement : Statement 79 class LabeledStatement : Statement
79 { 80 {
80 Token* label; 81 Identifier* label;
81 Statement s; 82 Statement s;
82 this(Token* label, Statement s) 83 this(Identifier* label, Statement s)
83 { 84 {
84 mixin(set_kind); 85 mixin(set_kind);
85 addChild(s); 86 addChild(s);
86 this.label = label; 87 this.label = label;
87 this.s = s; 88 this.s = s;
270 } 271 }
271 } 272 }
272 273
273 class ContinueStatement : Statement 274 class ContinueStatement : Statement
274 { 275 {
275 Token* ident; 276 Identifier* ident;
276 this(Token* ident) 277 this(Identifier* ident)
277 { 278 {
278 mixin(set_kind); 279 mixin(set_kind);
279 this.ident = ident; 280 this.ident = ident;
280 } 281 }
281 } 282 }
282 283
283 class BreakStatement : Statement 284 class BreakStatement : Statement
284 { 285 {
285 Token* ident; 286 Identifier* ident;
286 this(Token* ident) 287 this(Identifier* ident)
287 { 288 {
288 mixin(set_kind); 289 mixin(set_kind);
289 this.ident = ident; 290 this.ident = ident;
290 } 291 }
291 } 292 }
301 } 302 }
302 } 303 }
303 304
304 class GotoStatement : Statement 305 class GotoStatement : Statement
305 { 306 {
306 Token* ident; 307 Identifier* ident;
307 Expression caseExpr; 308 Expression caseExpr;
308 this(Token* ident, Expression caseExpr) 309 this(Identifier* ident, Expression caseExpr)
309 { 310 {
310 mixin(set_kind); 311 mixin(set_kind);
311 addOptChild(caseExpr); 312 addOptChild(caseExpr);
312 this.ident = ident; 313 this.ident = ident;
313 this.caseExpr = caseExpr; 314 this.caseExpr = caseExpr;
387 } 388 }
388 } 389 }
389 390
390 class ScopeGuardStatement : Statement 391 class ScopeGuardStatement : Statement
391 { 392 {
392 Token* condition; 393 Identifier* condition;
393 Statement scopeBody; 394 Statement scopeBody;
394 this(Token* condition, Statement scopeBody) 395 this(Identifier* condition, Statement scopeBody)
395 { 396 {
396 mixin(set_kind); 397 mixin(set_kind);
397 addChild(scopeBody); 398 addChild(scopeBody);
398 this.condition = condition; 399 this.condition = condition;
399 this.scopeBody = scopeBody; 400 this.scopeBody = scopeBody;
433 } 434 }
434 } 435 }
435 436
436 class AsmInstruction : Statement 437 class AsmInstruction : Statement
437 { 438 {
438 Token* ident; 439 Identifier* ident;
439 Expression[] operands; 440 Expression[] operands;
440 this(Token* ident, Expression[] operands) 441 this(Identifier* ident, Expression[] operands)
441 { 442 {
442 mixin(set_kind); 443 mixin(set_kind);
443 addOptChildren(operands); 444 addOptChildren(operands);
444 this.ident = ident; 445 this.ident = ident;
445 this.operands = operands; 446 this.operands = operands;
446 } 447 }
447 } 448 }
448 449
449 class AsmAlignStatement : Statement 450 class AsmAlignStatement : Statement
450 { 451 {
451 Token* number; 452 int number;
452 this(Token* number) 453 this(int number)
453 { 454 {
454 mixin(set_kind); 455 mixin(set_kind);
455 this.number = number; 456 this.number = number;
456 } 457 }
457 } 458 }
464 } 465 }
465 } 466 }
466 467
467 class PragmaStatement : Statement 468 class PragmaStatement : Statement
468 { 469 {
469 Token* ident; 470 Identifier* ident;
470 Expression[] args; 471 Expression[] args;
471 Statement pragmaBody; 472 Statement pragmaBody;
472 this(Token* ident, Expression[] args, Statement pragmaBody) 473 this(Identifier* ident, Expression[] args, Statement pragmaBody)
473 { 474 {
474 mixin(set_kind); 475 mixin(set_kind);
475 addOptChildren(args); 476 addOptChildren(args);
476 addChild(pragmaBody); 477 addChild(pragmaBody);
477 478
482 } 483 }
483 484
484 class MixinStatement : Statement 485 class MixinStatement : Statement
485 { 486 {
486 Expression[] templateIdents; 487 Expression[] templateIdents;
487 Token* mixinIdent; 488 Identifier* mixinIdent;
488 this(Expression[] templateIdents, Token* mixinIdent) 489 this(Expression[] templateIdents, Identifier* mixinIdent)
489 { 490 {
490 mixin(set_kind); 491 mixin(set_kind);
491 addChildren(templateIdents); 492 addChildren(templateIdents);
492 this.templateIdents = templateIdents; 493 this.templateIdents = templateIdents;
493 this.mixinIdent = mixinIdent; 494 this.mixinIdent = mixinIdent;
521 this.condition = condition; 522 this.condition = condition;
522 this.message = message; 523 this.message = message;
523 } 524 }
524 } 525 }
525 526
526 class DebugStatement : Statement 527 abstract class ConditionalCompilationStatement : Statement
527 { 528 {
528 Token* cond; 529 Token* cond;
529 Statement debugBody, elseBody; 530 Statement mainBody, elseBody;
530 this(Token* cond, Statement debugBody, Statement elseBody) 531 this(Token* cond, Statement mainBody, Statement elseBody)
531 { 532 {
532 mixin(set_kind); 533 addChild(mainBody);
533 addChild(debugBody);
534 addOptChild(elseBody); 534 addOptChild(elseBody);
535 this.cond = cond; 535 this.cond = cond;
536 this.debugBody = debugBody; 536 this.mainBody = mainBody;
537 this.elseBody = elseBody; 537 this.elseBody = elseBody;
538 } 538 }
539 } 539 }
540 540
541 class VersionStatement : Statement 541 class DebugStatement : ConditionalCompilationStatement
542 { 542 {
543 Token* cond; 543 this(Token* cond, Statement debugBody, Statement elseBody)
544 Statement versionBody, elseBody; 544 {
545 super(cond, debugBody, elseBody);
546 mixin(set_kind);
547 }
548 }
549
550 class VersionStatement : ConditionalCompilationStatement
551 {
545 this(Token* cond, Statement versionBody, Statement elseBody) 552 this(Token* cond, Statement versionBody, Statement elseBody)
546 { 553 {
547 mixin(set_kind); 554 super(cond, versionBody, elseBody);
548 addChild(versionBody); 555 mixin(set_kind);
549 addOptChild(elseBody); 556 }
550 this.cond = cond; 557 }
551 this.versionBody = versionBody;
552 this.elseBody = elseBody;
553 }
554 }