Ejemplo n.º 1
0
        public override void CheckSemantics(TigerScope scope, Report report)
        {
            ContainingScope = scope;

            //Check children
            LeftOperandNode.CheckSemantics(scope, report);
            RightOperandNode.CheckSemantics(scope, report);
            if (!LeftOperandNode.IsOK || !RightOperandNode.IsOK)
            {
                return;
            }

            //Check children types
            if ((TigerType.AreCompatible(LeftOperandNode.TigerType, TigerType.Int) && TigerType.AreCompatible(RightOperandNode.TigerType, TigerType.Int)) ||
                (TigerType.AreCompatible(LeftOperandNode.TigerType, TigerType.String) && TigerType.AreCompatible(RightOperandNode.TigerType, TigerType.String)))
            {
                TigerType = TigerType.Int;
            }
            else
            {
                report.AddError(SemanticErrors.InvalidOrderComparison(this, LeftOperandNode.TigerType,
                                                                      RightOperandNode.TigerType));
            }
        }