Ejemplo n.º 1
0
        public Module ReadModule(FileInfo file)
        {
            if (Log.IsDebugEnabled) {
                Log.Debug("Reading resource '" + file.FullName + "'");
            }

            return EPLModuleUtil.ReadFile(file);
        }
Ejemplo n.º 2
0
        public Module ReadModule(
            string resource,
            IResourceManager resourceManager)
        {
            if (Log.IsDebugEnabled) {
                Log.Debug("Reading resource '" + resource + "'");
            }

            return EPLModuleUtil.ReadResource(resource, resourceManager);
        }
Ejemplo n.º 3
0
        public Module ReadModule(Uri url)
        {
            if (Log.IsDebugEnabled) {
                Log.Debug("Reading resource from url: " + url);
            }

            using (var stream = new WebClient().OpenRead(url)) {
                return EPLModuleUtil.ReadInternal(stream, url.ToString(), false);
            }
        }
Ejemplo n.º 4
0
        public Module ReadModule(
            Stream stream,
            string uri)
        {
            if (Log.IsDebugEnabled) {
                Log.Debug("Reading module from input stream");
            }

            return EPLModuleUtil.ReadInternal(stream, uri, false);
        }
Ejemplo n.º 5
0
        public EPCompiled Compile(
            string epl,
            CompilerArguments arguments)
        {
            if (arguments == null) {
                arguments = new CompilerArguments(new Configuration());
            }

            using (arguments.Configuration.Container.EnterContextualReflection()) {
                try {
                    var module = EPLModuleUtil.ParseInternal(epl, null);
                    IList<Compilable> compilables = new List<Compilable>();
                    foreach (var item in module.Items.Where(m => !m.IsCommentOnly)) {
                        var stmtEpl = item.Expression;
                        compilables.Add(new CompilableEPL(stmtEpl));
                    }

                    // determine module name
                    var moduleName = DetermineModuleName(arguments.Options, module);
                    var moduleUses = DetermineModuleUses(moduleName, arguments.Options, module);

                    // get compile services
                    var compileTimeServices = GetCompileTimeServices(arguments, moduleName, moduleUses, false);
                    AddModuleImports(module.Imports, compileTimeServices);

                    // compile
                    return CompilerHelperModuleProvider.Compile(
                        compilables,
                        moduleName,
                        new EmptyDictionary<ModuleProperty, object>(),
                        compileTimeServices,
                        arguments.Options);
                }
                catch (EPCompileException) {
                    throw;
                }
                catch (ParseException t) {
                    throw new EPCompileException(
                        "Failed to parse: " + t.Message,
                        t,
                        new EmptyList<EPCompileExceptionItem>());
                }
                catch (Exception ex) {
                    throw new EPCompileException(ex.Message, ex, new EmptyList<EPCompileExceptionItem>());
                }
            }
        }
Ejemplo n.º 6
0
        public void TestParse()
        {
            object[][] testdata = new object[][] {
                new object[] {
                    "/* Comment One */ select * from A;\n" +
                    "/* Comment Two */  select   *  from  B ;\n",
                    new EPLModuleParseItem[] {
                        new EPLModuleParseItem("/* Comment One */ select * from A", 1, 0, 33),
                        new EPLModuleParseItem("/* Comment Two */  select   *  from  B", 2, 34, 73)
                    },
                },
                new object[] {
                    "select /* Comment One\n\r; */ *, ';', \";\" from A order by x;; ;\n\n \n;\n" +
                    "/* Comment Two */  select   *  from  B ;\n",
                    new EPLModuleParseItem[] {
                        new EPLModuleParseItem("select /* Comment One\n\r; */ *, ';', \";\" from A order by x", 1, 0, 57),
                        new EPLModuleParseItem("/* Comment Two */  select   *  from  B", 6, 63, 102)
                    },
                }
            };

            for (int i = 0; i < testdata.Length; i++)
            {
                string input = (string)testdata[i][0];
                EPLModuleParseItem[]       expected = (EPLModuleParseItem[])testdata[i][1];
                IList <EPLModuleParseItem> result   = EPLModuleUtil.Parse(input);

                Assert.AreEqual(expected.Length, result.Count);
                for (int j = 0; j < expected.Length; j++)
                {
                    string message = "failed at item " + i + " and segment " + j;
                    Assert.AreEqual(expected[j].Expression, result[j].Expression, message);
                    Assert.AreEqual(expected[j].LineNum, result[j].LineNum, message);
                    Assert.AreEqual(expected[j].StartChar, result[j].StartChar, message);
                    Assert.AreEqual(expected[j].EndChar, result[j].EndChar, message);
                }
            }
        }
Ejemplo n.º 7
0
 public static Module ReadFile(FileInfo file)
 {
     using (var inputStream = file.OpenRead()) {
         return EPLModuleUtil.ReadInternal(inputStream, file.FullName, false);
     }
 }
Ejemplo n.º 8
0
 public Module ParseModule(string eplModuleText)
 {
     return EPLModuleUtil.ParseInternal(eplModuleText, null);
 }