Пример #1
0
        private IFilterNode ParseComparisonExpression(IFilterNode firstArgument)
        {
            if (Is(FilterTokenType.ComparisonOperator))
            {
                FilterToken comparison = Expect(FilterTokenType.ComparisonOperator);

                IFilterNode secondArgument = PrimaryExpression();

                return(new ComparisonNode
                {
                    First = firstArgument,
                    FilterOperator = comparison.ToFilterOperator(),
                    Second = secondArgument
                });
            }

            FilterToken function = Expect(FilterTokenType.Function);

            var functionNode = new FunctionNode
            {
                FilterOperator = function.ToFilterOperator()
            };

            functionNode.Arguments.Add(firstArgument);
            functionNode.Arguments.Add(PrimaryExpression());

            return(functionNode);
        }
Пример #2
0
        private IFilterNode ParseFunctionExpression()
        {
            FilterToken function = Expect(FilterTokenType.Function);

            var functionNode = new FunctionNode
            {
                FilterOperator = function.ToFilterOperator()
            };

            Expect(FilterTokenType.LeftParenthesis);

            functionNode.Arguments.Add(Expression());

            while (Is(FilterTokenType.Comma))
            {
                Expect(FilterTokenType.Comma);
                functionNode.Arguments.Add(Expression());
            }

            Expect(FilterTokenType.RightParenthesis);

            return(functionNode);
        }