-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSyntaxObjects.cs
More file actions
1265 lines (1039 loc) · 26.9 KB
/
SyntaxObjects.cs
File metadata and controls
1265 lines (1039 loc) · 26.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
namespace Compiler
{
namespace Syntax
{
class Exception : Compiler.Exception
{
public Exception(string s, int index, int line) : base("Ошибка синтаксиса", s, index, line) { }
public Exception(Expression expr, string message)
: base("Ошибка синтаксиса", message, expr.GetIndex(), expr.GetLine()) { }
}
class CanNotCalculated : Compiler.Exception
{
Expression expr = null;
public CanNotCalculated(Expression expr, string message = "невозможно вычислить выражение")
: base("Ошибка синтаксиса", message, expr.GetIndex(), expr.GetLine())
{
this.expr = expr;
}
public Expression GetExpression()
{
return this.expr;
}
}
abstract class Object
{
protected int line = -1, pos = -1;
public int GetLine() { return line; }
public int GetIndex() { return this.pos; }
public static void CheckObject(Object obj, string text = "требуется выражение")
{
if (obj == null)
{
throw new Syntax.Exception(text, -1, -1);
}
}
public static void CheckToken(Token token, Token.Type type, string text)
{
if (token.type != type)
{
throw new Syntax.Exception(text, token.GetIndex(), token.GetLine());
}
}
abstract public List<Object> GetChildrens();
public void Print(StreamWriter stream, int indent = 0)
{
Stack<Three<Object, string, bool>> stack = new Stack<Three<Object, string, bool>>();
stack.Push(new Three<Object, string, bool>(this, new String(' ', indent), true));
while (stack.Count != 0)
{
Three<Object, string, bool> el = stack.Pop();
string s_indent = el.middle;
bool last = el.last;
Object obj = el.first;
stream.Write(s_indent);
stream.Write(last ? "└──" : "├──");
stream.WriteLine('{' + (obj != null ? obj.ToString() : "ERROR") + '}');
s_indent += last ? " " : "│ ";
List<Object> childrens = obj != null ? obj.GetChildrens() : new List<Object>();
for (int i = childrens.Count - 1; i >= 0; --i)
{
Object subobj = childrens.ElementAt(i);
stack.Push(new Three<Object, string, bool>(subobj, s_indent, i == childrens.Count - 1));
}
}
}
}
class Root : Object
{
List<Object> statments = new List<Object>();
public Root() { }
public void AddChild(Object stmt)
{
statments.Add(stmt);
}
override public List<Object> GetChildrens()
{
return this.statments;
}
override public string ToString()
{
return "";
}
}
#region Expression
abstract class Expression : Object
{
protected Symbols.Type type = new Symbols.SuperType();
protected bool lvalue = false;
public Expression() { }
public Expression(Token t)
{
this.pos = t.GetIndex();
this.line = t.GetLine();
}
virtual public int ComputeConstIntValue()
{
throw new CanNotCalculated(this, "требуется константное выражение");
}
public bool IsLvalue()
{
return this.lvalue;
}
public void SetType(Symbols.Type type)
{
this.type = type;
}
new public Symbols.Type GetType()
{
return this.type;
}
override public List<Object> GetChildrens()
{
return new List<Object>();
}
virtual public Expression Modified()
{
return this;
}
virtual public void GenerateCode(ICodeGen gen) { }
}
class EmptyExpression : Expression
{
public override string ToString()
{
return "empty expr";
}
}
abstract class Operator : Expression {
protected Token op = null;
public Operator() { }
public Operator(Token op) : base(op)
{
this.op = op;
}
public override string ToString()
{
return op.GetStrVal();
}
}
class UnaryOperator : Operator {
protected Expression operand = null;
protected bool prefix_operator = true;
public UnaryOperator(Token op, bool prefix_operator = true) : base(op)
{
this.prefix_operator = prefix_operator;
}
public void SetOperand(Expression operand)
{
Object.CheckObject(operand);
this.operand = operand;
Symatic.UnaryConvertResult res = Symatic.ConvertUnaryOperand(this.operand, this.op);
this.lvalue = res.lvalue;
this.type = res.type;
}
override public List<Object> GetChildrens()
{
List<Object> res = new List<Object>();
res.Add(operand);
return res;
}
override public int ComputeConstIntValue()
{
if (this.prefix_operator)
{
switch (this.op.type)
{
case Token.Type.OP_PLUS:
return +this.operand.ComputeConstIntValue();
case Token.Type.OP_MUL_ASSIGN:
return -this.operand.ComputeConstIntValue();
case Token.Type.OP_TILDE:
return ~this.operand.ComputeConstIntValue();
case Token.Type.OP_NOT:
return this.operand.ComputeConstIntValue() == 0 ? 1 : 0;
}
}
return base.ComputeConstIntValue();
}
public override string ToString()
{
return this.prefix_operator ? base.ToString() + '@' : '@' + base.ToString();
}
public override Expression Modified()
{
this.operand = this.operand.Modified();
return this;
}
}
class BinaryOperator : Operator
{
protected Expression left_operand, right_operand;
public BinaryOperator() { }
public BinaryOperator(Token op) : base(op) { }
public void SetLeftOperand(Expression expr)
{
Object.CheckObject(expr);
this.left_operand = expr;
this.CheckAndCastOperands();
}
public void SetRightOperand(Expression expr)
{
Object.CheckObject(expr);
this.right_operand = expr;
this.CheckAndCastOperands();
}
private void CheckAndCastOperands()
{
if (this.left_operand == null || this.right_operand == null)
{
return;
}
Symatic.BinaryConvertResult res = Symatic
.ConvertBinaryOperands(this.left_operand, this.right_operand, this.op);
this.type = res.type;
this.lvalue = res.lvalue;
}
public override int ComputeConstIntValue()
{
int l = this.left_operand.ComputeConstIntValue(),
r = this.right_operand.ComputeConstIntValue();
switch (this.op.type)
{
case Token.Type.OP_STAR:
return l * r;
case Token.Type.OP_MOD:
return l % r;
case Token.Type.OP_DIV:
return l / r;
case Token.Type.OP_PLUS:
return l + r;
case Token.Type.OP_SUB:
return l - r;
case Token.Type.OP_XOR:
return l ^ r;
case Token.Type.OP_BIT_AND:
return l & r;
case Token.Type.OP_BIT_OR:
return l | r;
case Token.Type.OP_AND:
return l != 0 && r != 0 ? 1 : 0;
case Token.Type.OP_OR:
return l != 0 || r != 0 ? 1 : 0;
case Token.Type.OP_EQUAL:
return l == r ? 1 : 0;
case Token.Type.OP_NOT_EQUAL:
return l != r ? 1 : 0;
case Token.Type.OP_MORE:
return l > r ? 1 : 0;
case Token.Type.OP_LESS:
return l < r ? 1 : 0;
case Token.Type.OP_MORE_OR_EQUAL:
return l >= r ? 1 : 0;
case Token.Type.OP_LESS_OR_EQUAL:
return l <= r ? 1 : 0;
case Token.Type.OP_L_SHIFT:
return l << r;
case Token.Type.OP_R_SHIFT:
return l >> r;
default:
return base.ComputeConstIntValue();
}
}
override public List<Object> GetChildrens()
{
List<Object> res = new List<Object>();
res.Add(left_operand);
res.Add(right_operand);
return res;
}
public override Expression Modified()
{
Symatic.BinaryConvertResult res =
Symatic.ConvertBinaryOperands(this.left_operand, this.right_operand, this.op);
this.left_operand = res.left.Modified();
this.right_operand = res.right.Modified();
this.op = res.op;
return this;
}
public override void GenerateCode(ICodeGen gen)
{
this.left_operand.GenerateCode(gen);
this.right_operand.GenerateCode(gen);
switch (this.op.type)
{
case Token.Type.OP_STAR: break;
case Token.Type.OP_ASSIGN: gen.Mov(); break;
case Token.Type.OP_MOD: gen.Mod(); break;
case Token.Type.OP_DIV: gen.Div(); break;
case Token.Type.OP_PLUS: gen.Add(); break;
case Token.Type.OP_SUB: gen.Sub(); break;
case Token.Type.OP_XOR: gen.Xor(); break;
case Token.Type.OP_BIT_AND: break;
case Token.Type.OP_BIT_OR: break;
case Token.Type.OP_AND: break;
case Token.Type.OP_OR: break;
case Token.Type.OP_EQUAL: break;
case Token.Type.OP_NOT_EQUAL: break;
case Token.Type.OP_MORE: break;
case Token.Type.OP_LESS: break;
case Token.Type.OP_MORE_OR_EQUAL: break;
case Token.Type.OP_LESS_OR_EQUAL: break;
case Token.Type.OP_L_SHIFT: break;
case Token.Type.OP_R_SHIFT: break;
}
}
}
class Refference : Operator
{
protected Expression expr, refference;
public Refference() { }
public Refference(Token t) : base(t) { }
public void SetExpression(Expression expr)
{
Object.CheckObject(expr);
this.expr = expr;
CheckAndCastOperands();
}
public void SetRefference(Expression refference)
{
Object.CheckObject(refference);
this.refference = refference;
CheckAndCastOperands();
}
private void CheckAndCastOperands()
{
if (this.expr == null || this.refference == null)
{
return;
}
Symatic.PostfixOperator t_op = Symatic.PostfixOperator.DOT;
switch (this.op.type)
{
case Token.Type.OP_REF:
t_op = Symatic.PostfixOperator.REF;
break;
case Token.Type.OP_DOT:
t_op = Symatic.PostfixOperator.DOT;
break;
case Token.Type.LBRACKET:
t_op = Symatic.PostfixOperator.INDEX;
break;
default:
throw new NotImplementedException();
}
Symatic.BinaryConvertResult res = Symatic
.PostfixConvertResult(this.expr, this.refference, t_op);
this.type = res.type;
this.lvalue = res.lvalue;
}
public override List<Object> GetChildrens()
{
List<Object> res = new List<Object>();
res.Add(this.expr);
res.Add(this.refference);
return res;
}
public override Expression Modified()
{
Expression res = null;
switch (this.op.type)
{
case Token.Type.LBRACKET:
BinaryOperator bop = new BinaryOperator(new Token(Token.Type.OP_PLUS));
if (this.expr is Refference && ((Refference)this.expr).op.type == Token.Type.LBRACKET)
{
UnaryOperator u = new UnaryOperator(new Token(Token.Type.OP_BIT_AND));
this.expr.SetType(((Symbols.RefType)this.expr.GetType()).GetRefType());
u.SetOperand(this.expr);
bop.SetRightOperand(u);
}
else
{
bop.SetRightOperand(this.expr);
}
bop.SetLeftOperand(this.refference);
res = new UnaryOperator(new Token(Token.Type.OP_STAR));
((UnaryOperator)res).SetOperand(bop);
break;
case Token.Type.OP_REF:
UnaryOperator rop = new UnaryOperator(new Token(Token.Type.OP_STAR));
rop.SetOperand(this.expr);
res = new Refference(new Token(Token.Type.OP_DOT));
((Refference)res).SetExpression(rop);
((Refference)res).SetRefference(this.refference);
break;
}
return res == null ? this : res.Modified();
}
}
class Cast : Operator
{
protected Expression operand = null;
protected Symbols.Type type_cast = null;
public Cast(Expression operand, Symbols.Type type)
{
this.SetOperand(operand);
this.SetTypeCast(type);
}
public Cast(Token op) : base(op) { }
public void SetOperand(Expression operand)
{
Object.CheckObject(operand);
this.operand = operand;
CheckOperands();
}
public void SetTypeCast(Symbols.Type type)
{
this.type_cast = type;
this.type = type;
CheckOperands();
}
override public List<Object> GetChildrens()
{
List<Object> res = new List<Object>();
res.Add(this.operand);
return res;
}
private void CheckOperands()
{
if (this.type_cast == null || this.operand == null || this.operand.GetType().Equals(this.type_cast))
{
return;
}
const string ERROR = "не существует преобразования из {0} в {1}";
if (this.operand.GetType() is Symbols.RECORD || this.type_cast is Symbols.RECORD ||
this.operand.GetType() is Symbols.VOID || this.type_cast is Symbols.VOID)
{
throw new Symbols.Exception(this.operand,
string.Format(ERROR, this.operand.GetType().ToString(), this.type_cast.ToString()));
}
}
public override string ToString()
{
return "cast(" + this.type.ToString() + ")";
}
public override Expression Modified()
{
this.operand = this.operand.Modified();
return this;
}
public override void GenerateCode(ICodeGen gen)
{
this.operand.GenerateCode(gen);
if (this.type_cast is Symbols.INT || this.type_cast is Symbols.POINTER)
{
gen.ToInt(this.type_cast.GetSizeType());
}
else if (this.type_cast is Symbols.CHAR)
{
gen.ToInt(this.type_cast.GetSizeType());
}
else if (this.type_cast is Symbols.DOUBLE)
{
gen.ToFloat(this.type_cast.GetSizeType());
}
}
}
class Call : Operator
{
protected Expression operand = null;
protected List<Expression> arguments = null;
public Call() { }
public Call(Token op) : base(op) { }
public void SetOperand(Expression operand)
{
Object.CheckObject(operand);
if (!(operand.GetType() is Symbols.Func))
{
throw new Exception(operand, "выражение должно представлять функцию");
}
this.operand = operand;
this.type = ((Symbols.Func)operand.GetType()).GetRefType();
this.Check();
}
public void SetArgumentList(List<Expression> args)
{
this.arguments = args;
this.Check();
}
private void Check()
{
if (this.arguments == null || this.operand == null)
{
return;
}
Symatic.CheckCallFunction(this.operand, this.arguments);
}
public override List<Object> GetChildrens()
{
List<Object> res = new List<Object>();
res.Add(this.operand);
if (this.arguments != null)
{
res.AddRange(this.arguments);
}
return res;
}
public override string ToString()
{
return "call";
}
public override Expression Modified()
{
List<Expression> args = new List<Expression>();
foreach (Expression arg in this.arguments)
{
args.Add(arg.Modified());
}
this.arguments = args;
this.operand = this.operand.Modified();
return this;
}
public override void GenerateCode(ICodeGen gen)
{
this.arguments.Reverse();
foreach (Expression arg in this.arguments)
{
arg.GenerateCode(gen);
}
this.arguments.Reverse();
this.operand.GenerateCode(gen);
gen.Call((Symbols.Func)this.operand.GetType());
for (int i = 0; i < this.arguments.Count; ++i )
{
gen.Pop();
}
}
}
class Ternary : BinaryOperator
{
protected Expression condition, branch_true, branch_false;
public Ternary(Expression cond)
{
this.SetCondition(cond);
}
public void SetCondition(Expression condition)
{
Object.CheckObject(condition);
this.condition = condition;
}
public void SetBranchTrue(Expression branch_true)
{
Object.CheckObject(branch_true);
this.branch_true = branch_true;
this.CheckAndCast();
}
public void SetBranchFalse(Expression branch_false)
{
Object.CheckObject(branch_false);
this.branch_false = branch_false;
this.CheckAndCast();
}
private void CheckAndCast()
{
this.type = this.branch_true.GetType();
if (this.branch_false == null || this.branch_true == null
|| this.branch_true.GetType().Equals(this.branch_false.GetType()))
{
return;
}
this.branch_false = new Cast(this.branch_false, this.branch_true.GetType());
}
override public List<Object> GetChildrens()
{
List<Object> res = new List<Object>();
res.Add(condition);
res.Add(branch_true);
res.Add(branch_false);
return res;
}
public override int ComputeConstIntValue()
{
return this.condition.ComputeConstIntValue() != 0 ? this.branch_true.ComputeConstIntValue() :
this.branch_false.ComputeConstIntValue();
}
public override string ToString()
{
return "ternary";
}
public override Expression Modified()
{
this.condition = this.condition.Modified();
this.branch_true = this.branch_true.Modified();
this.branch_false = this.branch_false.Modified();
return this;
}
}
class Const : Expression
{
protected string constant = null;
public Const(string value, Symbols.Type type)
{
this.SetType(type);
this.SetConstant(value);
}
public Const(Token constant, Symbols.Type type) : base(constant)
{
this.SetType(type);
this.SetConstant(constant);
}
public void SetConstant(string value)
{
if (this.type is Symbols.DOUBLE)
{
value = value.Replace(',', '.');
}
else if (this.type is Symbols.CHAR)
{
value = ((int)Convert.ToChar(value)).ToString();
}
this.constant = value;
}
public string GetValue()
{
return this.constant;
}
public void SetConstant(Token constant)
{
this.SetConstant(constant.GetStrVal());
this.pos = constant.GetIndex();
this.line = constant.GetLine();
}
public override int ComputeConstIntValue()
{
if (this.type is Symbols.INT)
{
return Int32.Parse(this.constant);
}
else if (this.type is Symbols.DOUBLE)
{
return (int)Double.Parse(this.constant);
}
else if (this.type is Symbols.CHAR)
{
return (int)Char.Parse(this.constant);
}
return base.ComputeConstIntValue();
}
public override string ToString()
{
return this.constant;
}
public override void GenerateCode(ICodeGen gen)
{
gen.Push(this);
}
}
class Identifier : Expression
{
protected Token identifier;
protected Symbols.Var variable = null;
public Identifier(Token identifier)
{
this.SetIdentifier(identifier);
this.lvalue = true;
}
public Identifier(Token identifier, Symbols.Var variable)
{
this.SetIdentifier(identifier);
this.SetVariable(variable);
this.lvalue = true;
}
public void SetIdentifier(Token identifier)
{
this.identifier = identifier;
this.line = identifier.line;
this.pos = identifier.pos;
}
public void SetVariable(Symbols.Var variable)
{
this.variable = variable;
this.type = variable.GetType();
}
public string GetName()
{
return this.identifier.GetStrVal();
}
public Symbols.Var GetVariable() { return this.variable; }
public override string ToString()
{
return this.identifier.GetStrVal();
}
public override void GenerateCode(ICodeGen gen)
{
gen.Push(this);
}
}
class Initializer : Expression {
protected List<Expression> init_list = new List<Expression>();
public Initializer() { }
public void AddInitializer(Expression init)
{
this.init_list.Add(init);
}
public override List<Object> GetChildrens()
{
List<Object> res = new List<Object>();
foreach (Object obj in this.init_list)
{
res.Add(obj);
}
return res;
}
public override string ToString()
{
return "init";
}
}
class InitializerList : Expression
{
public class Designation : Expression
{
protected Expression designator = null;
public Designation() { }
public override List<Object> GetChildrens()
{
return this.designator.GetChildrens();
}
public override string ToString()
{
return this.designator.ToString();
}
public void SetDesignator(Expression designator)
{
this.designator = designator;
}
}
protected List<Pair<Designation, Expression>> init_list = new List<Pair<Designation, Expression>>();
public InitializerList() { }
public void AddInitializer(Expression value, Designation designator = null)
{
Object.CheckObject(value);
this.init_list.Add(new Pair<Designation, Expression>(designator, value));
}
public override List<Object> GetChildrens()
{
return base.GetChildrens();
}
public override string ToString()
{
return "init list";
}
}
#endregion
#region Statement
abstract class Statement : Object
{
public override List<Object> GetChildrens()
{
return new List<Object>();
}
virtual public void Modified() { }
virtual public void GenerateCode(ICodeGen gen) { }
}
class IF : Statement
{
Expression condition;
Statement branch_true, branch_false;
public IF(Expression condition)
{
Object.CheckObject(condition);
this.condition = condition;
}
public void SetBranchTrue(Statement br)
{
Object.CheckObject(br);
this.branch_true = br;
}
public void SetBranchFalse(Statement br)
{
Object.CheckObject(br);
this.branch_false = br;
}
override public List<Object> GetChildrens()
{
List<Object> res = new List<Object>();
res.Add(condition);
res.Add(branch_true);
if (branch_false != null)
{
res.Add(branch_false);
}
return res;
}
public override string ToString()
{
return "if";
}
public override void Modified()
{
this.branch_false.Modified();
this.branch_true.Modified();
this.condition = this.condition.Modified();
}
}
class StatementExpression : Statement
{
protected Expression expression = new EmptyExpression();
public StatementExpression() { }
public StatementExpression(Expression expression)
{
this.SetExpression(expression);
}
public void SetExpression(Expression expression)
{
this.expression = expression == null ? new EmptyExpression() : expression;
}
public Expression GetExpression()
{
return this.expression == null? new EmptyExpression() : this.expression;
}
public override List<Object> GetChildrens()
{
return this.expression == null? new List<Object>(): this.expression.GetChildrens();
}
public override string ToString()
{
return this.expression == null ? "empty statement" : this.expression.ToString();
}
public override void Modified()
{