private void parseFromClause(FromQueryBodyClauseNode from) { setScannerState(from); var doParseType = true; if (isIdentifier(nextLexicalUnit(true))) { int sp = scanner.StartPosition; int len = getLexicalUnitLength(); var restorePoint = this.createRestorePoint(); if (nextLexicalUnit(true) == LexicalUnit.Keyword && scanner.Keyword == Keyword.In) { doParseType = false; from.NameOffset = sp; from.NameLength = len; } else { this.restore(restorePoint); } } if (doParseType) { from.Type = parseType(true); if (!isIdentifier(lexicalUnit)) { throw error(ParseErrorId.IdentifierExpected); } from.NameOffset = scanner.StartPosition; from.NameLength = getLexicalUnitLength(); nextLexicalUnit(true); } if (lexicalUnit != LexicalUnit.Keyword || scanner.Keyword != Keyword.In) { throw error(ParseErrorId.InExpected); } nextLexicalUnit(true); from.Origin = parseExpression(); from.EndPosition = from.Origin.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; }