コード例 #1
0
        public override void CheckSemantics(Scope scope, List <SemanticError> errors)
        {
            //--------------------------------------------------
            // Hacer 'CheckSemantics' Al Hijo.
            //--------------------------------------------------
            this.OperandNode.CheckSemantics(scope, errors);

            //--------------------------------------------------
            // Poner El Valor De Retorno De La Expresión A 'Error'
            // Por Default.
            //--------------------------------------------------
            this.ExpressionType = PredefinedTypes.ErrorType;

            //--------------------------------------------------
            // Si Ha Ocurrido Un Error En El Hijo, Parar De
            // Reportar Errores.
            //--------------------------------------------------
            if (this.OperandNode.ExpressionType == PredefinedTypes.ErrorType)
            {
                return;
            }

            //--------------------------------------------------
            // Comprobar Que El Tipo De La Expresión Del Hijo Sea <int>.
            //--------------------------------------------------
            if (this.OperandNode.ExpressionType == PredefinedTypes.IntType)
            {
                this.ExpressionType = PredefinedTypes.IntType;
            }
            else
            {
                errors.Add(SemanticError.InvalidUseOfUnaryMinusOperator(this));
            }
        }