public override void CheckSemantics(TigerScope scope, Report report) { ContainingScope = scope; //Check children Condition.CheckSemantics(scope, report); IfBlock.CheckSemantics(scope, report); if (!Condition.IsOK && !IfBlock.IsOK) { return; } TigerType = TigerType.Void; //Check condition type if (!TigerType.AreCompatible(TigerType.Int, Condition.TigerType)) { report.AddError(SemanticErrors.InvalidConditionType(Condition, Condition.TigerType)); TigerType = TigerType.Error; } if (!TigerType.AreCompatible(TigerType.Void, IfBlock.TigerType)) { report.AddError(SemanticErrors.InvalidIfBodyType(IfBlock)); TigerType = TigerType.Error; } }
public override void CheckSemantics(TigerScope scope, Report report) { ContainingScope = scope; //Checking children Condition.CheckSemantics(scope, report); IfBlock.CheckSemantics(scope, report); ElseBlock.CheckSemantics(scope, report); if (!Condition.IsOK || !IfBlock.IsOK || !ElseBlock.IsOK) { return; } TigerType = IfBlock.TigerType; //Checking children types if (!TigerType.AreCompatible(Condition.TigerType, TigerType.Int)) { report.AddError(SemanticErrors.InvalidConditionType(Condition, Condition.TigerType)); } if (!TigerType.AreCompatible(IfBlock.TigerType, ElseBlock.TigerType)) { report.AddError(SemanticErrors.IncompatibleIfElseReturnType(ElseBlock, IfBlock.TigerType, ElseBlock.TigerType)); } }
public override void CheckSemantics(TigerScope scope, Report report) { ContainingScope = scope; //Check children Condition.CheckSemantics(scope, report); InstructionNode.CheckSemantics(scope, report); if (!Condition.IsOK || !InstructionNode.IsOK) { return; } IsOK = true; //Check children types if (!TigerType.AreCompatible(Condition.TigerType, TigerType.Int)) { report.AddError(SemanticErrors.InvalidConditionType(Condition, Condition.TigerType)); IsOK = false; } if (!TigerType.AreCompatible(InstructionNode.TigerType, TigerType.Void)) { report.AddError(SemanticErrors.InvalidWhileBodyType(InstructionNode)); IsOK = false; } }