Пример #1
0
        protected virtual RqlExpression VisitFunctionCall(RqlFunctionCallExpression node)
        {
            for (int i = 0, n = node.Arguments.Count; i < n; i++)
            {
                this.Visit(node.Arguments[i]);
            }

            return node;
        }
Пример #2
0
        protected virtual RqlExpression VisitFunctionCall(RqlFunctionCallExpression node)
        {
            for (int i = 0, n = node.Arguments.Count; i < n; i++)
            {
                this.Visit(node.Arguments[i]);
            }

            return(node);
        }
Пример #3
0
        protected override RqlExpression VisitFunctionCall(RqlFunctionCallExpression node)
        {
            s += node.Name;
            s += "(";

            for (int i = 0, n = node.Arguments.Count; i < n; i++)
            {
                this.Visit(node.Arguments[i]);

                if (i < node.Arguments.Count - 1)
                    s += ",";
            }

            s += ")";

            return node;
        }
Пример #4
0
        public SortSpec Parse(string sortSpec)
        {
            this.input = sortSpec;

            string[] parts  = input.Split(',');
            var      fields = new List <SortSpecField>();

            foreach (var part in parts)
            {
                RqlFunctionCallExpression funcExp = null;

                try
                {
                    funcExp = new RqlParser().Parse(part) as RqlFunctionCallExpression;
                }
                catch (RqlParseException e)
                {
                    throw new SortSpecParserException("Sort specification must be of the form field(...)", e);
                }

                if (funcExp.Arguments.Count != 1)
                {
                    throw new SortSpecParserException("Sort specifications must have exactly one argument");
                }

                RqlConstantExpression constExp = funcExp.Arguments[0] as RqlConstantExpression;

                if (constExp == null || !(constExp.Value is Int32))
                {
                    throw new SortSpecParserException("Sort specification value must be an integer");
                }

                var value = (int)constExp.Value;

                if (value != 1 && value != -1)
                {
                    throw new SortSpecParserException("Sort specification value must be 1 or -1");
                }

                fields.Add(new SortSpecField(funcExp.Name, value == 1 ? SortSpecSortOrder.Ascending : SortSpecSortOrder.Descending));
            }

            return(new SortSpec(fields));
        }
Пример #5
0
        public FieldSpec Parse(string fieldSpec)
        {
            this.input = fieldSpec;

            string[] parts  = input.Split(',');
            var      fields = new List <FieldSpecField>();

            foreach (var part in parts)
            {
                RqlFunctionCallExpression funcExp = null;

                try
                {
                    funcExp = new RqlParser().Parse(part) as RqlFunctionCallExpression;
                }
                catch (RqlParseException e)
                {
                    throw new FieldSpecParserException("Field specification must be of the form field(...)", e);
                }

                if (funcExp.Arguments.Count != 1)
                {
                    throw new FieldSpecParserException("Field specifications must have exactly one argument");
                }

                RqlConstantExpression constExp = funcExp.Arguments[0] as RqlConstantExpression;

                if (constExp == null || !(constExp.Value is Int32))
                {
                    throw new FieldSpecParserException("Field specification must be an integer");
                }

                var value = (int)constExp.Value;

                if (value != 0 && value != 1)
                {
                    throw new FieldSpecParserException("Field specification value must be 0 or 1");
                }

                fields.Add(new FieldSpecField(funcExp.Name, value == 1 ? FieldSpecPresence.Included : FieldSpecPresence.Excluded));
            }

            return(new FieldSpec(fields));
        }