Exemplo n.º 1
0
        /// <summary>
        /// Parses an order term.
        /// Expression (ASC|DESC)?, (Expression (ASC|DESC)?)*
        /// </summary>
        /// <returns> An oder term node. </returns>
        private static Node ParseOrderTerm(ref int position, List <Token> tokens)
        {
            OrderTermNode orderTermNode = new OrderTermNode();

            // Expression
            var expression = ParseExpressionNode(ref position, tokens);

            if (expression == null)
            {
                ThrowError("Order by parser", "Expected expression.", position, tokens);
            }
            else
            {
                orderTermNode.AddExpression(expression);
            }

            // ASC|DESC
            orderTermNode.SetIsAscending(ParseAscDesc(ref position, tokens));

            // Comma singnals another order term.
            if (CheckToken(position, Token.TokenType.Comma, tokens))
            {
                position++;
                orderTermNode.AddNext(ParseOrderTerm(ref position, tokens));
            }

            return(orderTermNode);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Expects an expression node and possibly next order term node.
        /// </summary>
        public void Visit(OrderTermNode node)
        {
            if (node.exp == null)
            {
                throw new ArgumentNullException($"{this.GetType()}, failed access expression.");
            }
            else
            {
                node.exp.Accept(this);
            }

            this.result.Add(ExpressionComparer.Factory(this.expressionHolder, node.isAscending, false));

            if (node.next != null)
            {
                node.next.Accept(this);
            }
        }
Exemplo n.º 3
0
 public void Visit(OrderTermNode node)
 {
     throw new NotImplementedException();
 }