예제 #1
0
        public override void ValidateSemantic()
        {
            var valorType = eValor.EvaluateType();

            if ((!(valorType is IntType) && !(valorType is BoolType)))
            {
                throw new SemanticException("Invalid types.");
            }
        }
예제 #2
0
        public override Types EvaluateType()
        {
            var leftType  = leftOperand.EvaluateType();
            var rightType = rightOperand.EvaluateType();
            var rule      = leftType.GetType().Name + "," + rightType.GetType().Name;

            if (rules.ContainsKey(rule))
            {
                return(rules[rule]);
            }

            throw new SemanticException("Rule not supported");
        }
예제 #3
0
        public override Types EvaluateType(Types type)
        {
            if (!(type is ArrayType))
            {
                throw new SemanticException("Type must be an array!");
            }
            var arrType  = (ArrayType)type;
            var exprType = value.EvaluateType();

            if (!(exprType is IntType))
            {
                throw new SemanticException("Type must be an int!");
            }
            return(arrType.type);
        }
예제 #4
0
        public override void ValidateSemantic()
        {
            var valorType = eValor.EvaluateType();

            if (!SymbolsTable.vars.ContainsKey(id.ToString()))
            {
                SymbolsTable.vars[id.ToString()] = valorType;
                return;
            }
            var nodeType = id.EvaluateType();

            if (valorType.GetType() != nodeType.GetType())
            {
                throw new SemanticException("Incorrect assignation types.");
            }
        }