예제 #1
0
        private ExpressionNode parseQueryExpression() {
            var restorePoint = this.createRestorePoint();
            var result = new QueryExpressionNode();
            setScannerState(result);
            var doParseType = true;
			var lex = nextLexicalUnit(false);
            if (!(isIdentifier(lex) || (lex == LexicalUnit.Keyword && scanner.Keyword == Keyword.String))) {
                this.restore(restorePoint);
                return null;
            } else {
                int sp = scanner.StartPosition;
                int len = getLexicalUnitLength();
                switch (nextLexicalUnit(false)) {
                case SemiColon:
                case Assign:
                case Comma:
                    this.restore(restorePoint);
                    return null;

                case Keyword:
                    if (scanner.Keyword == Keyword.In) {
                        doParseType = false;
                        result.From.NameOffset = sp;
                        result.From.NameLength = len;
                        break;
                    }
                    goto default;
                    
                default:
                    this.restore(restorePoint);
                    nextLexicalUnit(true);
                    break;
                }
            }
            if (doParseType) {
                result.From.Type = parseType(false);
                if (result.From.Type == null) {
                    this.restore(restorePoint);
                    return null;
                }
                if (!isIdentifier(lexicalUnit)) {
                    this.restore(restorePoint);
                    return null;
                }
                result.From.NameOffset = scanner.StartPosition;
                result.From.NameLength = getLexicalUnitLength();
                nextLexicalUnit(true);
            }
            if (lexicalUnit != LexicalUnit.Keyword || scanner.Keyword != Keyword.In) {
                throw error(ParseErrorId.InExpected);
            }
            nextLexicalUnit(true);
            result.From.Origin = parseExpression();
            parseQueryBody(result.Body, result.From.Origin.EndPosition);
            result.EndPosition = result.Body.EndPosition;
            return result;
        }
예제 #2
0
 protected virtual TResult handleQuery(QueryExpressionNode query, TSource source, bool nested)
 {
     return(defaultHandler());
 }