public static ThemaCompilerContext Compile(string code, Action <ThemaProject> prepareProject = null) { var project = new ThemaProject { ErrorLevel = ErrorLevel.Error, UseEcoOptimization = true, UseEcoProcess = true }; project.SetSelfLog(LogLevel.Debug); project.NonResolvedProcessThemaRefIsError = true; project.CustomCompiler = new ApplyEcoProcesses(); project.DirectSource["main.bxl"] = code; if (null != prepareProject) { prepareProject(project); } var compiler = new ThemaCompiler(); var context = compiler.Compile(project); Console.WriteLine(project.GetLog()); foreach (var e in context.Errors) { Console.WriteLine(e); } return(context); }
public object Process() { var project = new SingleContentProject(Text); if (ProjBxl.IsNotEmpty()) { project.ConfigureFromXml(Application.Current.Bxl.Parse(ProjBxl)); } return new ThemaCompilerResultForQweb( LastContext = new ThemaCompiler().Compile( project)); }
public object Process() { var project = new SingleContentProject(Text); if (ProjBxl.IsNotEmpty()) { project.ConfigureFromXml(Application.Current.Bxl.Parse(ProjBxl)); } return(new ThemaCompilerResultForQweb( LastContext = new ThemaCompiler().Compile( project))); }
private ThemaCompilerContext exec(params string[] clusters) { var proj = new ThemaProject(); proj.DirectSource["main.bxl"] = code; proj.SetSelfLog(); proj.CustomCompiler = new GenerateXml(); if (null != clusters) { foreach (var cluster in clusters) { proj.Clusters.Add(cluster); } } var result = new ThemaCompiler().Compile(proj); foreach (var t in result.Themas) { Console.WriteLine(t.Value.Xml); } return result; }
/// <summary> /// </summary> /// <param name="args"> </param> /// <exception cref="Exception"></exception> public void Run(string[] args) { // Contract.Requires<ArgumentException>(args!=null && args.Length!=0); var project = new ThemaProject(); var projfile = Path.GetFullPath(args[0]); var dir = Path.GetDirectoryName(projfile); if (null == dir) { throw new Exception("не могу определить рабочую директорию"); } Environment.CurrentDirectory = dir; var projfilexml = Application.Current.Bxl.Parse(File.ReadAllText(projfile), Path.GetFileName(projfile)); IList<string> targets = new List<string>(); if (args.Length > 1) { for (var i = 1; i < args.Length; i++) { targets.Add(args[i]); } } project.ConfigureFromXml(projfilexml, string.Join(",", targets.ToArray())); Console.WriteLine("Project loaded from " + projfile); var compiler = new ThemaCompiler(); Console.WriteLine("Start of compilation"); Result = compiler.Compile(project); if (ErrorLevel.Warning <= project.ErrorLevel) { Console.ForegroundColor = ConsoleColor.Yellow; foreach (var warn in Result.Errors.Where(x => x.Level <= ErrorLevel.Warning)) { Console.WriteLine(warn); } Console.ResetColor(); } Console.ForegroundColor = ConsoleColor.Red; foreach (var error in Result.Errors.Where(x => x.Level > ErrorLevel.Warning)) { Console.WriteLine(error); } Console.ResetColor(); if (Result.IsComplete) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("compilation complete"); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("compilation failed!"); } Console.ResetColor(); }
protected ThemaCompilerContext execute <T>(ThemaProject proj = null, LogLevel level = LogLevel.Trace) where T : IThemaCompilerSetup, new() { sw = new StringWriter(); proj = proj ?? getDefaultProject(); proj.UserLog = proj.UserLog ?? BaseTextWriterLogWriter.CreateLog("default", sw, level); proj.CustomCompiler = proj.CustomCompiler ?? new T(); var compiler = new ThemaCompiler(); var result = compiler.Compile(proj); Console.WriteLine(sw.ToString()); foreach (var e in result.Errors) { Console.WriteLine(e); } return(result); }
public static ThemaCompilerContext Compile(string code, Action<ThemaProject> prepareProject = null) { var project = new ThemaProject {ErrorLevel = ErrorLevel.Error, UseEcoOptimization = true, UseEcoProcess = true}; project.SetSelfLog(LogLevel.Debug); project.NonResolvedProcessThemaRefIsError = true; project.CustomCompiler = new ApplyEcoProcesses(); project.DirectSource["main.bxl"] = code; if (null != prepareProject) { prepareProject(project); } var compiler = new ThemaCompiler(); var context = compiler.Compile(project); Console.WriteLine(project.GetLog()); foreach (var e in context.Errors) { Console.WriteLine(e); } return context; }
private ThemaCompilerContext exec(params string[] clusters) { var proj = new ThemaProject(); proj.DirectSource["main.bxl"] = code; proj.SetSelfLog(); proj.CustomCompiler = new GenerateXml(); if (null != clusters) { foreach (var cluster in clusters) { proj.Clusters.Add(cluster); } } var result = new ThemaCompiler().Compile(proj); foreach (var t in result.Themas) { Console.WriteLine(t.Value.Xml); } return(result); }