Ejemplo n.º 1
0
        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;
            }
        }