private ITermMatcher BuildMatcher(AstQuery ast)
        {
            var wordQuery = ast as WordAstQuery;

            if (wordQuery != null)
            {
                return(BuildWordMatcher(wordQuery));
            }

            var wildQuery = ast as WildcardAstQuery;

            if (wildQuery != null)
            {
                return(BuildWildcardMatcher(wildQuery));
            }

            var editQuery = ast as EditAstQuery;

            if (editQuery != null)
            {
                return(BuildEditMatcher(editQuery));
            }

            throw new Exception("Not a terminal query");
        }
        private ISearchQuery Compile(AstQuery ast)
        {
            if (ast == null)
            {
                throw new ArgumentNullException(nameof(ast));
            }

            if ((ast is WordAstQuery) ||
                (ast is WildcardAstQuery) ||
                (ast is EditAstQuery))
            {
                return(CompilePattern(index.GetTerms(BuildMatcher(ast))));
            }

            var func = ast as FunctionAstQuery;

            if (func != null)
            {
                if (func.Name == "OR")
                {
                    return(CompileOr(func));
                }
                else if (func.Name == "SEQ")
                {
                    return(CompileSeq(func));
                }
                else
                {
                    throw new NotSupportedException($"Function {func.Name} is not supported");
                }
            }

            throw new NotSupportedException($"Query {ast.Name} is not supported");
        }
        private ISearchQuery Compile(AstQuery ast)
        {
            if (ast == null)
            {
                throw new ArgumentNullException(nameof(ast));
            }

            var wordQuery = ast as WordAstQuery;

            if (wordQuery != null)
            {
                return(CompileWord(wordQuery));
            }

            var wildQuery = ast as WildcardAstQuery;

            if (wildQuery != null)
            {
                return(CompileWildcard(wildQuery));
            }

            var editQuery = ast as EditAstQuery;

            if (editQuery != null)
            {
                return(CompileEdit(editQuery));
            }

            var func = ast as FunctionAstQuery;

            if (func != null)
            {
                if (func.Name == "OR")
                {
                    return(CompileOr(func));
                }
                else if (func.Name == "SEQ")
                {
                    return(CompileSeq(func));
                }
                else
                {
                    throw new NotSupportedException($"Function {func.Name} is not supported");
                }
            }

            throw new NotSupportedException($"Query {ast.Name} is not supported");
        }
Esempio n. 4
0
 public ParseResult(AstQuery query, int position)
 {
     this.query    = query;
     this.position = position;
 }