public static EqlResult CompileWith(string query, Expression context, ISchemaProvider schemaProvider, IMethodProvider _methodProvider) { AntlrInputStream stream = new AntlrInputStream(query); var lexer = new EqlGrammerLexer(stream); var tokens = new CommonTokenStream(lexer); var parser = new EqlGrammerParser(tokens); parser.BuildParseTree = true; var tree = parser.startRule(); var visitor = new EqlGrammerVisitor(context, schemaProvider, _methodProvider); var expression = visitor.Visit(tree); return(new EqlResult(Expression.Lambda(expression))); }
public static EqlResult Compile(string query, ISchemaProvider schemaProvider, IMethodProvider _methodProvider) { ParameterExpression contextParam = null; if (schemaProvider != null) { contextParam = Expression.Parameter(schemaProvider.ContextType); } AntlrInputStream stream = new AntlrInputStream(query); var lexer = new EqlGrammerLexer(stream); var tokens = new CommonTokenStream(lexer); var parser = new EqlGrammerParser(tokens); parser.BuildParseTree = true; var tree = parser.startRule(); var visitor = new EqlGrammerVisitor(contextParam, schemaProvider, _methodProvider); var expression = visitor.Visit(tree); return(new EqlResult(contextParam != null ? Expression.Lambda(expression, contextParam) : Expression.Lambda(expression))); }