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); }
public QueryCompiler( IQueryFactory queryFactory, IRuntime runtime, IQueryViewRepository queryViewRepository, [Import(typeof(AggregateQueryErrorListener))] IQueryErrorListener queryErrorListener) { _queryFactory = queryFactory; _runtime = runtime; _queryQueryErrorListener = queryErrorListener; Views = queryViewRepository; }
public QueryCompilationListener( IQueryFactory queryFactory, QueryCompiler compiler, IQueryErrorListener errorListener, IRuntime runtime, QueryCompilationParameters parameters) { _queryFactory = queryFactory; _compiler = compiler; _errorListener = errorListener; _runtime = runtime; _parameters = parameters; }
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; }
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(); }
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); } } }
public IExecutableQuery Compile(TextReader reader, IQueryErrorListener listener) { return(Compile(reader, listener, new QueryCompilationParameters())); }
public LexerErrorListener(IQueryErrorListener listener) { _queryErrorListener = listener; }
public ParserErrorListener(IQueryErrorListener listener) { _queryErrorListener = listener; }