Example #1
0
        private IType checkPredicate(Context context)
        {
            IType lt = left.check(context);

            if (lt is IterableType)
            {
                IType           itemType = ((IterableType)lt).GetItemType();
                ArrowExpression arrow    = ((PredicateExpression)right).ToArrowExpression();
                return(arrow.CheckFilter(context, itemType));
            }
            else
            {
                throw new SyntaxError("Expecting collection");
            }
        }
Example #2
0
        public override IType check(Context context)
        {
            IType sourceType = source.check(context);

            if (!(sourceType is IterableType))
            {
                throw new SyntaxError("Expecting an iterable type as data source!");
            }
            IType           itemType   = ((IterableType)sourceType).GetItemType();
            ArrowExpression arrow      = predicate.ToArrowExpression();
            IType           filterType = arrow.CheckFilter(context, itemType);

            if (filterType != BooleanType.Instance)
            {
                throw new SyntaxError("Filtering expresion must return a bool!");
            }
            return(new ListType(itemType));
        }