private void parseOrderbyClause(OrderbyQueryBodyClauseNode orderby) { setScannerState(orderby); int endPosition; do { nextLexicalUnit(true); var ordering = new OrderingNode(); setScannerState(ordering); ordering.KeySelector = parseExpression(); endPosition = ordering.KeySelector.EndPosition; if (lexicalUnit == LexicalUnit.ContextualKeyword) { switch (scanner.Keyword) { case Ascending: endPosition = scanner.EndPosition; nextLexicalUnit(true); break; case Descending: endPosition = scanner.EndPosition; nextLexicalUnit(true); ordering.Descending = true; break; } } ordering.EndPosition = endPosition; orderby.Orderings.add(ordering); } while (lexicalUnit == LexicalUnit.Comma); orderby.EndPosition = endPosition; }
private void parseQueryBody(QueryBodyNode body, int endPosition) { var done = false; do { switch (lexicalUnit) { case ContextualKeyword: case Keyword: switch (scanner.Keyword) { case From: var from = new FromQueryBodyClauseNode(); parseFromClause(from); body.Clauses.add(from); endPosition = from.EndPosition; break; case Join: var join = new JoinQueryBodyClauseNode(); parseJoinClause(join); body.Clauses.add(join); endPosition = join.EndPosition; break; case Let: var let = new LetQueryBodyClauseNode(); parseLetClause(let); body.Clauses.add(let); endPosition = let.EndPosition; break; case Orderby: var orderby = new OrderbyQueryBodyClauseNode(); parseOrderbyClause(orderby); body.Clauses.add(orderby); endPosition = orderby.EndPosition; break; case Where: var where = new WhereQueryBodyClauseNode(); parseWhereClause(where); body.Clauses.add(where); endPosition = where.EndPosition; break; default: done = true; break; } break; default: done = true; break; } } while (!done); switch (lexicalUnit) { case ContextualKeyword: case Keyword: switch (scanner.Keyword) { case Select: nextLexicalUnit(true); body.SelectOrGroup = parseExpression(); endPosition = body.SelectOrGroup.EndPosition; break; case Group: nextLexicalUnit(true); body.SelectOrGroup = parseExpression(); if (lexicalUnit != LexicalUnit.ContextualKeyword || scanner.Keyword != Keyword.By) { throw error(ParseErrorId.ByExpected); } nextLexicalUnit(true); body.By = parseExpression(); endPosition = body.By.EndPosition; break; default: throw error(ParseErrorId.SelectOrGroupExpected); } break; default: throw error(ParseErrorId.SelectOrGroupExpected); } if (lexicalUnit == LexicalUnit.ContextualKeyword && scanner.Keyword == Keyword.Into) { if (!isIdentifier(nextLexicalUnit(true))) { throw error(ParseErrorId.IdentifierExpected); } body.Continuation = new QueryContinuationNode { NameOffset = scanner.StartPosition, NameLength = getLexicalUnitLength() }; endPosition = scanner.EndPosition; nextLexicalUnit(true); parseQueryBody(body.Continuation.Body, endPosition); endPosition = body.Continuation.Body.EndPosition; } body.EndPosition = endPosition; }