Example #1
0
        private SqlOrderByEntryNode ParseOrderTerm(ITokenizer t)
        {
            // ( <QualifiedIdentifier> | <Number> ) ("ASC" | "DESC")?
            var identifier = ParseQualifiedIdentifier(t);

            if (identifier == null)
            {
                if (t.Peek().IsType(SqlTokenType.Number))
                {
                    var number = t.GetNext();
                    identifier = new SqlNumberNode(number);
                }
            }

            if (identifier == null)
            {
                throw ParsingException.CouldNotParseRule(nameof(ParseOrderTerm), t.Peek());
            }
            var entry = new SqlOrderByEntryNode
            {
                Location = identifier.Location,
                Source   = identifier
            };
            var next = t.Peek();

            if (next.IsKeyword("ASC") || next.IsKeyword("DESC"))
            {
                t.GetNext();
                entry.Direction = next.Value;
            }

            return(entry);
        }
 public ISqlNode VisitNumber(SqlNumberNode n)
 {
     Append(n.ToString());
     return(n);
 }
Example #3
0
 public virtual ISqlNode VisitNumber(SqlNumberNode n) => n;