protected override void CustomizeCompiler(Boo.Lang.Compiler.BooCompiler compiler, Boo.Lang.Compiler.CompilerPipeline pipeline, string[] urls) { compiler.Parameters.Ducky = true; compiler.Parameters.GenerateInMemory = false; pipeline.Insert(1, new Rhino.DSL.ImplicitBaseClassCompilerStep(typeof(DslParser), "CalculateValue", "System", "AI.TextFileParsing.DSL.Extensions", "AI.TextFileParsing.DSL")); }
protected override void CustomizeCompiler(Boo.Lang.Compiler.BooCompiler compiler, Boo.Lang.Compiler.CompilerPipeline pipeline, string[] urls) { Logger log = LogManager.GetCurrentClassLogger(); compiler.Parameters.Ducky = true; compiler.Parameters.Debug = true; pipeline.Insert(1, new ImplicitBaseClassCompilerStep(typeof(ProcessDefDSLBase), "Prepare", _namespaces)); }
protected override void CustomizeCompiler(Boo.Lang.Compiler.BooCompiler compiler, Boo.Lang.Compiler.CompilerPipeline pipeline, string[] urls) { compiler.Parameters.Ducky = true; var customStep = new AnonymousBaseClassCompilerStep(typeof(ArghSettings), "Build", "Argh"); pipeline.Insert(1, customStep); pipeline.Insert(2, new UseSymbolsStep()); pipeline.InsertBefore(typeof(ProcessMethodBodiesWithDuckTyping), new CapitalisationCompilerStep()); pipeline.InsertBefore(typeof(ProcessMethodBodiesWithDuckTyping), new UnderscorNamingConventionsToPascalCaseCompilerStep()); compiler.Parameters.Pipeline.Replace(typeof(ProcessMethodBodiesWithDuckTyping), new UnknownHashLiteralKeyToStringLiteral()); }
public ScripterBoo() { //Notes on threads: http://www.yoda.arachsys.com/csharp/threads/ //IMPORTANT: runtime compiling of Boo code in this project. The following files must be referenced for this to work: //Boo.Lang.dll Boo.Lang.Compiler.dll Boo.Lang.Interpreter.dll Boo.Lang.Parser.dll _interpreter = new InteractiveInterpreter(); // Otherwise the line above will cause an exception! _defaultContext = ""; this._compiler = new Boo.Lang.Compiler.BooCompiler(); this._compiler.Parameters.Pipeline = new CompileToMemory(); //No need for an on-disk file. this._compiler.Parameters.Ducky = true; //By default, all objects will be ducked typed; no need for the user to "var as string" anywhere. this._instanceIdToObject = new Hashtable(); this._instanceIdToClass = new Hashtable(); this._stalledScripts = new Hashtable(); }
void AssertCultureDependentMessage(string message, CultureInfo culture) { var savedCulture = Thread.CurrentThread.CurrentUICulture; Thread.CurrentThread.CurrentUICulture = culture; try { var compiler = new Boo.Lang.Compiler.BooCompiler(); var options = compiler.Parameters; options.Input.Add(new Boo.Lang.Compiler.IO.StringInput("testcase", TestCase)); options.Pipeline = new Boo.Lang.Compiler.Pipelines.Parse(); var errors = compiler.Run().Errors; Assert.IsTrue(errors.Count >= 1); Assert.AreEqual(message, errors[0].Message); } finally { Thread.CurrentThread.CurrentUICulture = savedCulture; } }
private static CompilerResults CompileBoo(string[] sourceFiles, string[] referencedAssemblies) { // Prepare parameters var cp = new Boo.Lang.Compiler.CompilerParameters(); cp.Pipeline = new CompileToMemory(); cp.Ducky = true; cp.Debug = true; cp.OutputType = Boo.Lang.Compiler.CompilerOutputType.Library; cp.DefaultMethodVisibility = Boo.Lang.Compiler.Ast.TypeMemberModifiers.Public; // References cp.References.Add(typeof(System.Windows.Forms.Form).Assembly); cp.References.Add(typeof(System.Drawing.Color).Assembly); cp.References.Add(typeof(System.Xml.XmlDocument).Assembly); // .NET 3.5 if (Net35) { if (coreAssembly == null) { coreAssembly = Assembly.LoadWithPartialName("System.Core"); } cp.References.Add(coreAssembly); } // Add input files foreach (string file in sourceFiles) { string ext = Path.GetExtension(file); if (String.Compare(ext, ".boo", StringComparison.InvariantCultureIgnoreCase) == 0) { cp.Input.Add(new Boo.Lang.Compiler.IO.FileInput(file)); } else if (ext.ToLowerInvariant() == ".resx") { cp.Resources.Add(new Boo.Lang.Compiler.Resources.EmbeddedFileResource(file)); } } if (cp.Input.Count == 0) { // Nothing to compile return null; } // Create compiler Boo.Lang.Compiler.BooCompiler booc = new Boo.Lang.Compiler.BooCompiler(cp); var ctx = booc.Run(); // Convert result CompilerResults result = new CompilerResults(null); result.CompiledAssembly = ctx.GeneratedAssembly; result.Output.Add(booc.GetType().AssemblyQualifiedName); result.Output.Add(""); foreach (Boo.Lang.Compiler.CompilerWarning w in ctx.Warnings) { result.Output.Add(w.ToString()); } foreach (Boo.Lang.Compiler.CompilerError e in ctx.Errors) { result.Output.Add(e.ToString()); result.Errors.Add(new CompilerError(e.LexicalInfo.FileName, e.LexicalInfo.Line, e.LexicalInfo.Column, e.Code, e.Message)); } return result; }
private static CompilerResults CompileBoo(string[] sourceFiles, string[] referencedAssemblies) { // Prepare parameters var cp = new Boo.Lang.Compiler.CompilerParameters(); cp.Pipeline = new CompileToMemory(); cp.Ducky = true; cp.Debug = true; cp.OutputType = Boo.Lang.Compiler.CompilerOutputType.Library; cp.DefaultMethodVisibility = Boo.Lang.Compiler.Ast.TypeMemberModifiers.Public; // References cp.References.Add(typeof(System.Windows.Forms.Form).Assembly); cp.References.Add(typeof(System.Drawing.Color).Assembly); cp.References.Add(typeof(System.Xml.XmlDocument).Assembly); // .NET 3.5 if (Net35) { if (coreAssembly == null) { coreAssembly = Assembly.LoadWithPartialName("System.Core"); } cp.References.Add(coreAssembly); } // Add input files foreach (string file in sourceFiles) { string ext = Path.GetExtension(file); if (String.Compare(ext, ".boo", StringComparison.InvariantCultureIgnoreCase) == 0) { cp.Input.Add(new Boo.Lang.Compiler.IO.FileInput(file)); } else if (ext.ToLowerInvariant() == ".resx") { cp.Resources.Add(new Boo.Lang.Compiler.Resources.EmbeddedFileResource(file)); } } if (cp.Input.Count == 0) { // Nothing to compile return(null); } // Create compiler Boo.Lang.Compiler.BooCompiler booc = new Boo.Lang.Compiler.BooCompiler(cp); var ctx = booc.Run(); // Convert result CompilerResults result = new CompilerResults(null); result.CompiledAssembly = ctx.GeneratedAssembly; result.Output.Add(booc.GetType().AssemblyQualifiedName); result.Output.Add(""); foreach (Boo.Lang.Compiler.CompilerWarning w in ctx.Warnings) { result.Output.Add(w.ToString()); } foreach (Boo.Lang.Compiler.CompilerError e in ctx.Errors) { result.Output.Add(e.ToString()); result.Errors.Add(new CompilerError(e.LexicalInfo.FileName, e.LexicalInfo.Line, e.LexicalInfo.Column, e.Code, e.Message)); } return(result); }
public void SetUpFixture() { _compiler = new Boo.Lang.Compiler.BooCompiler(); _compiler.Parameters.OutputWriter = new StringWriter(); _compiler.Parameters.Pipeline = CreatePipeline(); }