private INotificationManager Conditional_Expression_Is_BoolType(Conditional conditional)
        {
            INotificationManager notificationManager = new NotificationManager();

            Types.Type type = conditional.Condition.Accept(new ExpressionTypeCollector(identifierToType));

            if (!type.IsEqual(new Types.BoolType()))
            {
                notificationManager.AddNotification(new NonBooleanCondition(conditional.GetPosition()));
            }

            return(notificationManager);
        }
Exemplo n.º 2
0
        private INotificationManager VisitUnaryExpectedType(Unary node, Types.Type expectedType)
        {
            INotificationManager notificationManager = node.GetChildExpression().Accept(this);

            Types.Type childType = node.GetChildExpression().Accept(new ExpressionTypeCollector(idToType));

            if (childType.IsEqual(expectedType))
            {
                notificationManager.AddNotification(new IncompatibleUnaryOperator(node, childType));
            }

            return(notificationManager);
        }
Exemplo n.º 3
0
        private INotificationManager VisitBinary(Binary node)
        {
            INotificationManager notificationManager = CollectChildrenErrors(node.Left(), node.Right());

            Types.Type left  = node.Left().Accept(new ExpressionTypeCollector(idToType));
            Types.Type right = node.Right().Accept(new ExpressionTypeCollector(idToType));

            if (!left.IsEqual(right))
            {
                notificationManager.AddNotification(new IncompatibleBinaryOperator(node, left, right));
            }

            return(notificationManager);
        }
Exemplo n.º 4
0
        private INotificationManager VisitBinaryExpectedType(Binary node, Types.Type expectedType)
        {
            INotificationManager notificationManager = new NotificationManager();

            Types.Type left  = node.Left().Accept(new ExpressionTypeCollector(idToType));
            Types.Type right = node.Right().Accept(new ExpressionTypeCollector(idToType));

            if (!(left.IsEqual(expectedType) && right.IsEqual(expectedType)))
            {
                notificationManager.AddNotification(new IncompatibleBinaryOperator(node, left, right));
            }

            return(notificationManager);
        }
        public INotificationManager Visit(Question question)
        {
            INotificationManager notificationManager = new NotificationManager();

            if (question.Computation != null)
            {
                notificationManager.Combine(Expression_Arguments_Are_Compatible(question.Computation));

                Types.Type type = question.Computation.Accept(new ExpressionTypeCollector(identifierToType));

                if (!type.IsEqual(question.RetrieveType()))
                {
                    notificationManager.AddNotification(new ComputedQuestionTypeConflict(question, type));
                }
            }

            return(notificationManager);
        }