public void SyntaxValidate( Module module, CompilerArguments arguments) { if (arguments == null) { arguments = new CompilerArguments(new Configuration()); } // determine module name var moduleName = DetermineModuleName(arguments.Options, module); var moduleUses = DetermineModuleUses(moduleName, arguments.Options, module); var moduleCompileTimeServices = GetCompileTimeServices(arguments, moduleName, moduleUses, false); var statementNumber = 0; try { foreach (var item in module.Items) { var services = new StatementCompileTimeServices(statementNumber, moduleCompileTimeServices); if (item.IsCommentOnly) { continue; } if (item.Expression != null && item.Model != null) { throw new EPCompileException( "Module item has both an EPL expression and a statement object model"); } if (item.Expression != null) { CompilerHelperSingleEPL.ParseCompileInlinedClassesWalk(new CompilableEPL(item.Expression), services); } else if (item.Model != null) { CompilerHelperSingleEPL.ParseCompileInlinedClassesWalk(new CompilableSODA(item.Model), services); item.Model.ToEPL(); } else { throw new EPCompileException( "Module item has neither an EPL expression nor a statement object model"); } statementNumber++; } } catch (Exception ex) { throw new EPCompileException(ex.Message, ex); } }
public StatementSpecRaw ParseWalk( string epl, StatementSpecMapEnv mapEnv) { return CompilerHelperSingleEPL.ParseWalk(epl, mapEnv); }
public static EPCompiled Compile( Compilable compilable, ModuleCompileTimeServices services, CompilerArguments args) { var compileTimeServices = new StatementCompileTimeServices(0, services); var walkResult = CompilerHelperSingleEPL.ParseCompileInlinedClassesWalk(compilable, compileTimeServices); var raw = walkResult.StatementSpecRaw; var statementType = StatementTypeUtil.GetStatementType(raw); if (statementType != StatementType.SELECT) { // the fire-and-forget spec is null for "select" and populated for I/U/D throw new StatementSpecCompileException( "Provided EPL expression is a continuous query expression (not an on-demand query)", compilable.ToEPL()); } var annotations = AnnotationUtil.CompileAnnotations( raw.Annotations, services.ImportServiceCompileTime, compilable); // walk subselects, alias expressions, declared expressions, dot-expressions var visitor = StatementSpecRawWalkerSubselectAndDeclaredDot.WalkSubselectAndDeclaredDotExpr(raw); // compile context descriptor ContextCompileTimeDescriptor contextDescriptor = null; var optionalContextName = raw.OptionalContextName; if (optionalContextName != null) { var detail = services.ContextCompileTimeResolver.GetContextInfo(optionalContextName); if (detail == null) { throw new StatementSpecCompileException( "Context by name '" + optionalContextName + "' could not be found", compilable.ToEPL()); } contextDescriptor = new ContextCompileTimeDescriptor( optionalContextName, detail.ContextModuleName, detail.ContextVisibility, new ContextPropertyRegistry(detail), detail.ValidationInfos); } var statementNameFromAnnotation = GetNameFromAnnotation(annotations); var statementName = statementNameFromAnnotation == null ? GetDefaultStatementName() : statementNameFromAnnotation.Trim(); var statementRawInfo = new StatementRawInfo( 0, statementName, annotations, statementType.Value, contextDescriptor, null, compilable, null); StatementSpecCompiledDesc compiledDesc = StatementRawCompiler.Compile( raw, compilable, false, true, annotations, visitor.Subselects, new List<ExprTableAccessNode>(raw.TableExpressions), statementRawInfo, compileTimeServices); StatementSpecCompiled specCompiled = compiledDesc.Compiled; var fafSpec = specCompiled.Raw.FireAndForgetSpec; //var @namespace = "generated"; var classPostfix = IdentifierUtil.GetIdentifierMayStartNumeric(statementName); EPCompiledManifest manifest; Assembly assembly; FAFQueryMethodForge query; if (specCompiled.Raw.InsertIntoDesc != null) { query = new FAFQueryMethodIUDInsertIntoForge( specCompiled, compilable, statementRawInfo, compileTimeServices); } else if (fafSpec == null) { // null indicates a select-statement, same as continuous query var desc = new FAFQueryMethodSelectDesc( specCompiled, compilable, statementRawInfo, compileTimeServices); var classNameResultSetProcessor = CodeGenerationIDGenerator.GenerateClassNameSimple( typeof(ResultSetProcessorFactoryProvider), classPostfix); query = new FAFQueryMethodSelectForge(desc, classNameResultSetProcessor, statementRawInfo); } else if (fafSpec is FireAndForgetSpecDelete) { query = new FAFQueryMethodIUDDeleteForge( specCompiled, compilable, statementRawInfo, compileTimeServices); } else if (fafSpec is FireAndForgetSpecUpdate) { query = new FAFQueryMethodIUDUpdateForge( specCompiled, compilable, statementRawInfo, compileTimeServices); } else { throw new IllegalStateException("Unrecognized FAF code " + fafSpec); } // verify substitution parameters VerifySubstitutionParams(raw.SubstitutionParameters); try { manifest = CompileToAssembly(query, classPostfix, args.Options, services, out assembly); } catch (EPCompileException) { throw; } catch (Exception ex) { throw new EPCompileException( "Unexpected exception compiling module: " + ex.Message, ex, new EmptyList<EPCompileExceptionItem>()); } return new EPCompiled(new [] { assembly }, manifest); }