コード例 #1
0
ファイル: QueryCompiler.cs プロジェクト: trylock/viewer
        internal IExecutableQuery Compile(
            TextReader inputQuery,
            IQueryErrorListener queryErrorListener,
            QueryCompilationParameters parameters)
        {
            // create all necessary components to parse a query
            var input = new AntlrInputStream(inputQuery);
            var lexer = new QueryLexer(input);

            lexer.AddErrorListener(new LexerErrorListener(queryErrorListener));

            var compiler = new QueryCompilationListener(
                _queryFactory,
                this,
                queryErrorListener,
                _runtime,
                parameters);

            var tokenStream   = new CommonTokenStream(lexer);
            var errorListener = new ParserErrorListener(queryErrorListener);
            var parser        = new QueryParser(tokenStream);

            parser.AddErrorListener(errorListener);

            // parse and compile the query
            if (!parameters.IsRecursiveCall)
            {
                queryErrorListener.BeforeCompilation();
            }

            IQuery result;

            try
            {
                var tree = parser.entry();
                ParseTreeWalker.Default.Walk(compiler, tree);
                result = compiler.Finish();

                if (result == null)
                {
                    return(null);
                }

                result = result.WithText(input.ToString());
            }
            catch (ParseCanceledException)
            {
                // an error has already been reported
                return(null);
            }
            finally
            {
                if (!parameters.IsRecursiveCall)
                {
                    queryErrorListener.AfterCompilation();
                }
            }

            return(result);
        }
コード例 #2
0
ファイル: QueryCompiler.cs プロジェクト: trylock/viewer
 public QueryCompiler(
     IQueryFactory queryFactory,
     IRuntime runtime,
     IQueryViewRepository queryViewRepository,
     [Import(typeof(AggregateQueryErrorListener))] IQueryErrorListener queryErrorListener)
 {
     _queryFactory            = queryFactory;
     _runtime                 = runtime;
     _queryQueryErrorListener = queryErrorListener;
     Views = queryViewRepository;
 }
コード例 #3
0
ファイル: QueryCompiler.cs プロジェクト: trylock/viewer
 public QueryCompilationListener(
     IQueryFactory queryFactory,
     QueryCompiler compiler,
     IQueryErrorListener errorListener,
     IRuntime runtime,
     QueryCompilationParameters parameters)
 {
     _queryFactory  = queryFactory;
     _compiler      = compiler;
     _errorListener = errorListener;
     _runtime       = runtime;
     _parameters    = parameters;
 }
コード例 #4
0
 public Editor(
     IFileSystem fileSystem,
     IFileSystemErrorView dialogView,
     IQueryHistory queryHistory,
     IQueryCompiler queryCompiler,
     IQueryErrorListener queryErrorListener,
     IQuerySuggestions querySuggestions)
 {
     _fileSystem         = fileSystem;
     _dialogView         = dialogView;
     _queryHistory       = queryHistory;
     _queryCompiler      = queryCompiler;
     _queryErrorListener = queryErrorListener;
     _querySuggestions   = querySuggestions;
 }
コード例 #5
0
        public QueryEditorPresenter(
            IQueryEditorView view,
            IFileSystemErrorView dialogErrorView,
            IQueryHistory appHistory,
            IQueryCompiler queryCompiler,
            IQueryErrorListener queryErrorListener,
            IQuerySuggestions querySuggestions,
            IEditor editor)
        {
            View                = view;
            _dialogErrorView    = dialogErrorView;
            _queryCompiler      = queryCompiler;
            _queryErrorListener = queryErrorListener;
            _querySuggestions   = querySuggestions;
            _appHistory         = appHistory;
            _editor             = editor;

            SubscribeTo(View, "View");

            _queryCompiler.Views.Changed += QueryViewsOnChanged;
            UpdateViews();
        }
コード例 #6
0
        public Runtime(
            IValueConverter converter,
            [Import(typeof(AggregateQueryErrorListener))] IQueryErrorListener queryErrorListener,
            [ImportMany] IFunction[] functions)
        {
            _converter          = converter;
            _queryErrorListener = queryErrorListener;

            foreach (var function in functions)
            {
                var normalizedFunctionName = NormalizeFunctionName(function.Name);
                if (!_functions.TryGetValue(normalizedFunctionName, out var functionList))
                {
                    functionList = new List <IFunction> {
                        function
                    };
                    _functions.Add(normalizedFunctionName, functionList);
                }
                else
                {
                    functionList.Add(function);
                }
            }
        }
コード例 #7
0
ファイル: QueryCompiler.cs プロジェクト: trylock/viewer
 public IExecutableQuery Compile(TextReader reader, IQueryErrorListener listener)
 {
     return(Compile(reader, listener, new QueryCompilationParameters()));
 }
コード例 #8
0
ファイル: QueryCompiler.cs プロジェクト: trylock/viewer
 public LexerErrorListener(IQueryErrorListener listener)
 {
     _queryErrorListener = listener;
 }
コード例 #9
0
ファイル: QueryCompiler.cs プロジェクト: trylock/viewer
 public ParserErrorListener(IQueryErrorListener listener)
 {
     _queryErrorListener = listener;
 }