/// <summary>nothing has been pre-consumed</summary> /// <returns>null if there is no order by</returns> /// <exception cref="System.SqlSyntaxErrorException" /> protected internal virtual OrderBy OrderBy() { if (lexer.Token() != MySqlToken.KwOrder) { return(null); } lexer.NextToken(); Match(MySqlToken.KwBy); var expr = exprParser.Expression(); var order = SortOrder.Asc; OrderBy orderBy; switch (lexer.Token()) { case MySqlToken.KwDesc: { order = SortOrder.Desc; goto case MySqlToken.KwAsc; } case MySqlToken.KwAsc: { if (lexer.NextToken() != MySqlToken.PuncComma) { return(new OrderBy(expr, order)); } goto case MySqlToken.PuncComma; } case MySqlToken.PuncComma: { orderBy = new OrderBy(); orderBy.AddOrderByItem(expr, order); break; } default: { return(new OrderBy(expr, order)); } } for (; lexer.Token() == MySqlToken.PuncComma;) { lexer.NextToken(); order = SortOrder.Asc; expr = exprParser.Expression(); switch (lexer.Token()) { case MySqlToken.KwDesc: { order = SortOrder.Desc; goto case MySqlToken.KwAsc; } case MySqlToken.KwAsc: { lexer.NextToken(); break; } } orderBy.AddOrderByItem(expr, order); } return(orderBy); }