public static void Main(params string[] args) { MMap<string, Pair<string, string>> KnownOptions = LeMP.Compiler.KnownOptions; if (args.Length != 0) { Severity minSeverity = Severity.Note; #if DEBUG minSeverity = Severity.Debug; #endif var filter = new SeverityMessageFilter(MessageSink.Console, minSeverity); LeMP.Compiler c = new LeMP.Compiler(filter, typeof(LeMP.Prelude.BuiltinMacros)); var argList = args.ToList(); var options = c.ProcessArguments(argList, false, true); if (options != null) { LeMP.Compiler.WarnAboutUnknownOptions(options, MessageSink.Console, KnownOptions.With("nologo", Pair.Create("",""))); if (c != null) { c.MacroProcessor.PreOpenedNamespaces.Add(GSymbol.Get("LeMP.Prelude.Les")); c.MacroProcessor.PreOpenedNamespaces.Add(GSymbol.Get("LeMP.Prelude")); c.MacroProcessor.PreOpenedNamespaces.Add(Loyc.LLPG.Macros.MacroNamespace); c.AddMacros(typeof(LeMP.StandardMacros).Assembly); c.AddMacros(Assembly.GetExecutingAssembly()); c.Run(); } } } else { LeMP.Compiler.ShowHelp(KnownOptions.OrderBy(p => p.Key)); Test_LLLPG(); } }
[STAThread] // Required by ICSharpCode.TextEditor public static void Main(string[] args) { BMultiMap<string,string> options = new BMultiMap<string,string>(); var argList = args.ToList(); UG.ProcessCommandLineArguments(argList, options, "", ShortOptions, TwoArgOptions); if (!options.ContainsKey("nologo")) Console.WriteLine("LeMP macro compiler (pre-alpha)"); string _; if (options.TryGetValue("help", out _) || options.TryGetValue("?", out _)) { ShowHelp(KnownOptions.OrderBy(p => p.Key)); return; } if (options.ContainsKey("editor")) { Console.WriteLine("Starting editor..."); System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); System.Windows.Forms.Application.Run(new TextEditor.LempDemoForm()); return; } Severity minSeverity = Severity.Note; #if DEBUG minSeverity = Severity.Debug; #endif var filter = new SeverityMessageFilter(MessageSink.Console, minSeverity); Compiler c = ProcessArguments(options, filter, typeof(Macros), argList); Compiler.WarnAboutUnknownOptions(options, MessageSink.Console, KnownOptions); if (c != null) { c.AddMacros(typeof(global::LeMP.StandardMacros).Assembly); c.MacroProcessor.PreOpenedNamespaces.Add(GSymbol.Get("LeMP.Prelude")); c.MacroProcessor.PreOpenedNamespaces.Add(GSymbol.Get("LeMP")); using (LNode.PushPrinter(Ecs.EcsNodePrinter.PrintPlainCSharp)) c.Run(); } else if (args.Length == 0) { ShowHelp(KnownOptions.OrderBy(p => p.Key)); Console.WriteLine(); Console.WriteLine("LeMP started without arguments. Starting editor (--editor)"); var thread = new ThreadEx(() => { System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.Run(new TextEditor.LempDemoForm()); }); thread.Thread.SetApartmentState(ApartmentState.STA); thread.Start(); Console.WriteLine("Press Enter to run unit tests. Using the editor? Keep the terminal open."); Console.ReadLine(); RunTests.Run(new Loyc.Syntax.Lexing.TokenTests()); RunTests.Run(new Loyc.Syntax.Les.LesLexerTests()); RunTests.Run(new Loyc.Syntax.Les.LesParserTests()); RunTests.Run(new Loyc.Syntax.Les.LesPrinterTests()); RunLeMPTests(); Ecs.Program.RunEcsTests(); } }
public static Compiler ProcessArguments(BMultiMap <string, string> options, SeverityMessageFilter sink, Type prelude, List <string> inputFiles) { if (inputFiles.Count == 0) { sink.Write(Severity.Error, null, "No input provided, stopping."); return(null); } Compiler c = new Compiler(sink, prelude); c.Files = new List <InputOutput>(OpenSourceFiles(sink, inputFiles)); return(ProcessArguments(c, options) ? c : null); }
public static void Main(string[] args) { // Acquire a log for, well, logging purposes. var rawLog = TerminalLog.Acquire(); Log = new TransformLog( rawLog, entry => DiagnosticExtractor.Transform(entry, new Text("LeMP-repl"))); // Wrap the log in a Loyc message sink. Sink = new SeverityMessageFilter( new PixieMessageSink(Log), Loyc.Severity.NoteDetail); // Create an option parser. var optParser = new GnuOptionSetParser( Options.All, Options.Files, Options.Files.Forms[0]); // Parse command-line arguments. var parsedOptions = optParser.Parse(args, Log); // Optionally display help message. if (parsedOptions.GetValue <bool>(Options.Help)) { rawLog.Log( new HelpMessage( "LeMP-repl is a simple interactive program that " + "reads unprocessed EC#, LES v2 or LES v3 code as " + "input and produces processed or unprocessed EC#, " + "LES v2 or LES v3 code as output.", "LeMP-repl [options]", Options.All)); return; } // Create a macro processor. if (!parsedOptions.GetValue <bool>(Options.DoNotProcessMacros)) { Processor = new MacroProcessor(Sink); Processor.AddMacros(typeof(StandardMacros).Assembly, false); Processor.PreOpenedNamespaces.Add(GSymbol.Get("LeMP")); } Parser = GetParser(parsedOptions); Printer = GetPrinter(parsedOptions); // Start the REPL. RunRepl(); }
[STAThread] // Required by ICSharpCode.TextEditor public static void Main(string[] args) { BMultiMap <string, string> options = new BMultiMap <string, string>(); var argList = args.ToList(); UG.ProcessCommandLineArguments(argList, options, "", ShortOptions, TwoArgOptions); if (!options.ContainsKey("nologo")) { Console.WriteLine("LeMP macro compiler (beta)"); } string _; if (options.TryGetValue("help", out _) || options.TryGetValue("?", out _)) { ShowHelp(KnownOptions.OrderBy(p => p.Key)); return; } if (options.ContainsKey("editor")) { Console.WriteLine("Starting editor..."); System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); System.Windows.Forms.Application.Run(new TextEditor.LempDemoForm()); return; } Severity minSeverity = Severity.Note; #if DEBUG minSeverity = Severity.Debug; #endif var filter = new SeverityMessageFilter(MessageSink.Console, minSeverity); Compiler c = ProcessArguments(options, filter, typeof(BuiltinMacros), argList); Compiler.WarnAboutUnknownOptions(options, MessageSink.Console, KnownOptions); if (c != null) { c.AddMacros(typeof(global::LeMP.StandardMacros).Assembly); c.MacroProcessor.PreOpenedNamespaces.Add(GSymbol.Get("LeMP.Prelude")); c.MacroProcessor.PreOpenedNamespaces.Add(GSymbol.Get("LeMP")); using (LNode.PushPrinter(EcsNodePrinter.PrintPlainCSharp)) c.Run(); } else if (args.Length == 0) { ShowHelp(KnownOptions.OrderBy(p => p.Key)); } }
[STAThread] // Required by ICSharpCode.TextEditor public static void Main(string[] args) { if (!args.Contains("--nologo")) { Console.WriteLine("LeMP macro compiler ({0})", typeof(Compiler).Assembly.GetName().Version.ToString()); } Severity minSeverity = Severity.NoteDetail; #if DEBUG minSeverity = Severity.DebugDetail; #endif var filter = new SeverityMessageFilter(ConsoleMessageSink.Value, minSeverity); Compiler c = new Compiler(filter, typeof(BuiltinMacros)); var argList = args.ToList(); var options = c.ProcessArguments(argList, false, true); if (options == null) { return; // error occurred, message should have printed already } if (!MaybeShowHelp(options, KnownOptions)) { WarnAboutUnknownOptions(options, filter, KnownOptions); if (c.Files.Count == 0) { Console.WriteLine(); filter.Error(null, "No input files provided, stopping. Add --help for usage info.".Localized()); if (!options.ContainsKey("nologo")) { // Give users a simple way to find out which copy they're using: // Windows doesn't have `which` and the dotnet tools version of // LeMP.exe is not the real one anyway (it's not a .NET module) Console.WriteLine("You're using {0}".Localized(typeof(MacroProcessor).Assembly.Location)); Console.WriteLine(" ({0})".Localized(typeof(MacroProcessor).Assembly.FullName)); } return; } else { using (LNode.SetPrinter(EcsLanguageService.WithPlainCSharpPrinter)) c.Run(); } } }
public static void Main(params string[] args) { IDictionary <string, Pair <string, string> > KnownOptions = LeMP.Compiler.KnownOptions; if (args.Length != 0) { BMultiMap <string, string> options = new BMultiMap <string, string>(); var argList = args.ToList(); UG.ProcessCommandLineArguments(argList, options, "", LeMP.Compiler.ShortOptions, LeMP.Compiler.TwoArgOptions); if (!options.ContainsKey("nologo")) { Console.WriteLine("LLLPG/LeMP macro compiler"); } string _; if (options.TryGetValue("help", out _) || options.TryGetValue("?", out _) || args.Length == 0) { LeMP.Compiler.ShowHelp(KnownOptions.OrderBy(p => p.Key)); return; } Severity minSeverity = Severity.Note; #if DEBUG minSeverity = Severity.Debug; #endif var filter = new SeverityMessageFilter(MessageSink.Console, minSeverity); LeMP.Compiler c = LeMP.Compiler.ProcessArguments(options, filter, typeof(LeMP.Prelude.Les.Macros), argList); LeMP.Compiler.WarnAboutUnknownOptions(options, MessageSink.Console, KnownOptions); if (c != null) { c.MacroProcessor.PreOpenedNamespaces.Add(GSymbol.Get("LeMP.Prelude")); c.MacroProcessor.PreOpenedNamespaces.Add(Loyc.LLPG.Macros.MacroNamespace); c.AddMacros(Assembly.GetExecutingAssembly()); c.AddMacros(typeof(LeMP.Prelude.Macros).Assembly); c.Run(); } } else { LeMP.Compiler.ShowHelp(KnownOptions.OrderBy(p => p.Key)); Tests(); Ecs.Program.Main(args); // do EC# tests } }
[STAThread] // Required by ICSharpCode.TextEditor public static void Main(string[] args) { if (!args.Contains("--nologo")) { Console.WriteLine("LeMP macro compiler ({0})", typeof(Compiler).Assembly.GetName().Version.ToString()); } if (args.Contains("--editor")) { Console.WriteLine("Starting editor..."); System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); System.Windows.Forms.Application.Run(new TextEditor.LempDemoForm()); return; } KnownOptions["editor"] = Pair.Create("", "Show built-in text editor"); Severity minSeverity = Severity.NoteDetail; #if DEBUG minSeverity = Severity.DebugDetail; #endif var filter = new SeverityMessageFilter(ConsoleMessageSink.Value, minSeverity); Compiler c = new Compiler(filter, typeof(BuiltinMacros)); var argList = args.ToList(); var options = c.ProcessArguments(argList, false, true); if (options == null) { return; // error occurred, message should have printed already } if (argList.Count == 0) { filter.Error(null, "No input files provided, stopping."); return; } if (!MaybeShowHelp(options, KnownOptions)) { WarnAboutUnknownOptions(options, filter, KnownOptions.With("nologo", Pair.Create("", ""))); using (LNode.SetPrinter(EcsLanguageService.WithPlainCSharpPrinter)) c.Run(); } }
public static void Main(string[] args) { BMultiMap <string, string> options = new BMultiMap <string, string>(); var argList = args.ToList(); UG.ProcessCommandLineArguments(argList, options, "", ShortOptions, TwoArgOptions); if (!options.ContainsKey("nologo")) { Console.WriteLine("LeMP macro compiler (pre-alpha)"); } string _; if (options.TryGetValue("help", out _) || options.TryGetValue("?", out _)) { ShowHelp(KnownOptions.OrderBy(p => p.Key)); return; } Severity minSeverity = Severity.Note; #if DEBUG minSeverity = Severity.Debug; #endif var filter = new SeverityMessageFilter(MessageSink.Console, minSeverity); Compiler c = ProcessArguments(argList, options, filter, typeof(Macros)); Compiler.WarnAboutUnknownOptions(options, MessageSink.Console, KnownOptions); if (c != null) { c.MacroProcessor.PreOpenedNamespaces.Add(GSymbol.Get("LeMP.Prelude")); using (LNode.PushPrinter(Ecs.EcsNodePrinter.PrintPlainCSharp)) c.Run(); } else if (args.Length == 0) { Console.WriteLine("Running unit tests..."); RunTests.Run(new Loyc.Syntax.Les.LesLexerTests()); RunTests.Run(new Loyc.Syntax.Les.LesParserTests()); RunLeMPTests(); Ecs.Program.RunEcsTests(); } }
public static void Main(params string[] args) { MMap <string, Pair <string, string> > KnownOptions = LeMP.Compiler.KnownOptions; if (args.Length != 0) { Severity minSeverity = Severity.NoteDetail; #if DEBUG minSeverity = Severity.DebugDetail; #endif var filter = new SeverityMessageFilter(ConsoleMessageSink.Value, minSeverity - 1); LeMP.Compiler c = new LeMP.Compiler(filter, typeof(LeMP.Prelude.BuiltinMacros)); var argList = args.ToList(); var options = c.ProcessArguments(argList, false, true); if (!LeMP.Compiler.MaybeShowHelp(options, KnownOptions)) { LeMP.Compiler.WarnAboutUnknownOptions(options, ConsoleMessageSink.Value, KnownOptions.With("nologo", Pair.Create("", ""))); if (c.Files.Count == 0) { ConsoleMessageSink.Value.Warning(null, "No files specified, stopping."); } else { c.MacroProcessor.PreOpenedNamespaces.Add(GSymbol.Get("LeMP.Prelude.Les")); c.MacroProcessor.PreOpenedNamespaces.Add(GSymbol.Get("LeMP.Prelude")); c.MacroProcessor.PreOpenedNamespaces.Add(Loyc.LLPG.Macros.MacroNamespace); c.AddMacros(typeof(LeMP.StandardMacros).Assembly); c.AddMacros(Assembly.GetExecutingAssembly()); c.Run(); } } } else { LeMP.Compiler.ShowHelp(KnownOptions.OrderBy(p => p.Key)); Test_LLLPG(); } }
public void DeprecatedMacros() { var msgs = new MessageHolder(); var msgs2 = new SeverityMessageFilter(msgs, Severity.Warning); Test("#importMacros(LeMP.Tests); DeprecatedMacro(); deprecatedMacro();", "DeprecatedMacro(); groovy_macro_dude;", 1, Les2LanguageService.Value, Les2LanguageService.Value, msgs2); Assert.IsTrue(msgs.List.First().Format.Contains("deprecated")); Assert.IsTrue(msgs.List.First().Formatted.Contains("This macro is sooo last century")); msgs.List.Clear(); Test(@"#importMacros(LeMP.Tests); nonDeprecatedAlias(); deprecatedAlias();" , @"multi_name_macro; multi_name_macro;" , 1, Les2LanguageService.Value, Les2LanguageService.Value, msgs2); Assert.IsTrue(msgs.List.First().Format.Contains("deprecated")); Assert.AreEqual(3, ((SourceRange)msgs.List.First().Location).Start.Line); Assert.IsTrue(msgs.List.First().Formatted.Contains("nonDeprecatedAlias")); }
public static void Main(params string[] args) { IDictionary<string, Pair<string, string>> KnownOptions = LeMP.Compiler.KnownOptions; if (args.Length != 0) { BMultiMap<string,string> options = new BMultiMap<string,string>(); var argList = args.ToList(); UG.ProcessCommandLineArguments(argList, options, "", LeMP.Compiler.ShortOptions, LeMP.Compiler.TwoArgOptions); if (!options.ContainsKey("nologo")) Console.WriteLine("LLLPG/LeMP macro compiler"); string _; if (options.TryGetValue("help", out _) || options.TryGetValue("?", out _) || args.Length == 0) { LeMP.Compiler.ShowHelp(KnownOptions.OrderBy(p => p.Key)); return; } Severity minSeverity = Severity.Note; #if DEBUG minSeverity = Severity.Debug; #endif var filter = new SeverityMessageFilter(MessageSink.Console, minSeverity); LeMP.Compiler c = LeMP.Compiler.ProcessArguments(options, filter, typeof(LeMP.Prelude.Les.Macros), argList); LeMP.Compiler.WarnAboutUnknownOptions(options, MessageSink.Console, KnownOptions); if (c != null) { c.MacroProcessor.PreOpenedNamespaces.Add(GSymbol.Get("LeMP.Prelude")); c.MacroProcessor.PreOpenedNamespaces.Add(Loyc.LLPG.Macros.MacroNamespace); c.AddMacros(Assembly.GetExecutingAssembly()); c.AddMacros(typeof(LeMP.Prelude.Macros).Assembly); c.Run(); } } else { LeMP.Compiler.ShowHelp(KnownOptions.OrderBy(p => p.Key)); Tests(); Ecs.Program.Main(args); // do EC# tests } }
[STAThread] // Required by ICSharpCode.TextEditor public static void Main(string[] args) { if (!args.Contains("--nologo")) Console.WriteLine("LeMP macro compiler ({0})", typeof(Compiler).Assembly.GetName().Version.ToString()); if (args.Contains("--editor")) { Console.WriteLine("Starting editor..."); System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); System.Windows.Forms.Application.Run(new TextEditor.LempDemoForm()); return; } KnownOptions["editor"] = Pair.Create("", "Show built-in text editor"); Severity minSeverity = Severity.Note; #if DEBUG minSeverity = Severity.Debug; #endif var filter = new SeverityMessageFilter(MessageSink.Console, minSeverity); Compiler c = new Compiler(filter, typeof(BuiltinMacros)); var argList = args.ToList(); var options = c.ProcessArguments(argList, false, true); if (argList.Count == 0) { filter.Write(Severity.Error, null, "No input files provided, stopping."); return; } if (!MaybeShowHelp(options, KnownOptions)) { WarnAboutUnknownOptions(options, filter, KnownOptions.With("nologo", Pair.Create("", ""))); using (LNode.PushPrinter(EcsNodePrinter.PrintPlainCSharp)) c.Run(); } }
protected override byte[] Generate(string inputFilePath, string inputFileContents, string defaultNamespace, IVsGeneratorProgress progressCallback) { string oldCurDir = Environment.CurrentDirectory; try { string inputFolder = Path.GetDirectoryName(inputFilePath); Environment.CurrentDirectory = inputFolder; // --macros should be relative to file being processed var options = new BMultiMap <string, string>(); var argList = G.SplitCommandLineArguments(defaultNamespace); UG.ProcessCommandLineArguments(argList, options, "", LeMP.Compiler.ShortOptions, LeMP.Compiler.TwoArgOptions); string _; var KnownOptions = LeMP.Compiler.KnownOptions; if (options.TryGetValue("help", out _) || options.TryGetValue("?", out _)) { LeMP.Compiler.ShowHelp(KnownOptions); } // Originally I wrote a conversion from IVsGeneratorProgress to // IMessageSink so that errors could be reported immediately and // directly to Visual Studio. This broke in a bizarre way when I // added processing on a separate thread (in order to be able to // abort the thread if it runs too long); I got the following // InvalidCastException: "Unable to cast COM object of type 'System.__ComObject' // to interface type 'Microsoft.VisualStudio.Shell.Interop.IVsGeneratorProgress'. // This operation failed because the QueryInterface call on the COM component for // the interface with IID '{BED89B98-6EC9-43CB-B0A8-41D6E2D6669D}' failed due to // the following error: No such interface supported (Exception from HRESULT: // 0x80004002 (E_NOINTERFACE))." // // A simple solution is to store the messages rather than reporting // them immediately. I'll report the errors at the very end. MessageHolder innerSink = new MessageHolder(); // Block verbose messages when --verbose is not specified Severity sev = Severity.Note; string value; if (options.TryGetValue("verbose", out value) && (value != "false")) { if (!Enum.TryParse(value, out sev)) { sev = Severity.Verbose; } } var sink = new SeverityMessageFilter(innerSink, sev); var sourceFile = new InputOutput((StringSlice)inputFileContents, inputFilePath); var c = new Compiler(sink, sourceFile); c.Parallel = false; // only one file, parallel doesn't help if (LeMP.Compiler.ProcessArguments(c, options)) { if (options.ContainsKey("no-out-header")) { options.Remove("no-out-header", 1); c.NoOutHeader = true; } LeMP.Compiler.WarnAboutUnknownOptions(options, sink, KnownOptions); if (c != null) { if (inputFilePath.EndsWith(".les", StringComparison.OrdinalIgnoreCase)) { c.MacroProcessor.PreOpenedNamespaces.Add(GSymbol.Get("LeMP.Prelude.Les")); } Configure(c); c.Run(); // Report errors foreach (var msg in innerSink.List) { ReportErrorToVS(progressCallback, msg.Severity, msg.Context, msg.Format, msg.Args); } return(Encoding.UTF8.GetBytes(c.Output.ToString())); } } return(null); } finally { Environment.CurrentDirectory = oldCurDir; } }
public virtual int Generate(string inputFilePath, string inputFileContents, string defaultNamespace, IntPtr[] outputFileContents, out uint outputSize, IVsGeneratorProgress progressCallback) { string inputFolder = Path.GetDirectoryName(inputFilePath); string oldCurDir = Environment.CurrentDirectory; try { Environment.CurrentDirectory = inputFolder; // --macros should be relative to file being processed var sourceFile = new StringCharSourceFile(inputFileContents, inputFilePath); var sink = ToMessageSink(progressCallback); var c = new Compiler(sink, sourceFile); var options = new BMultiMap<string, string>(); var argList = G.SplitCommandLineArguments(defaultNamespace); UG.ProcessCommandLineArguments(argList, options, "", LEL.Compiler.ShortOptions, LEL.Compiler.TwoArgOptions); string _; var KnownOptions = LEL.Compiler.KnownOptions; if (options.TryGetValue("help", out _) || options.TryGetValue("?", out _)) LEL.Compiler.ShowHelp(KnownOptions); Symbol minSeverity = MessageSink.Note; var filter = new SeverityMessageFilter(MessageSink.Console, minSeverity); if (LEL.Compiler.ProcessArguments(c, options)) { LEL.Compiler.WarnAboutUnknownOptions(options, MessageSink.Console, KnownOptions); if (c != null) { c.MacroProcessor.PreOpenedNamespaces.Add(GSymbol.Get("LEL.Prelude")); c.MacroProcessor.PreOpenedNamespaces.Add(GSymbol.Get("Loyc.LLParserGenerator")); c.AddMacros(typeof(Loyc.LLParserGenerator.Macros).Assembly); c.Run(); } var outputBytes = Encoding.UTF8.GetBytes(c.Output.ToString()); c.Output = null; // no longer needed outputSize = (uint)outputBytes.Length; outputFileContents[0] = Marshal.AllocCoTaskMem(outputBytes.Length); Marshal.Copy(outputBytes, 0, outputFileContents[0], outputBytes.Length); } else { outputFileContents[0] = IntPtr.Zero; outputSize = 0; } return VSConstants.S_OK; } finally { Environment.CurrentDirectory = oldCurDir; } }
public static Compiler ProcessArguments(List <string> inputFiles, BMultiMap <string, string> options, SeverityMessageFilter sink, Type prelude) { if (inputFiles.Count == 0) { sink.Write(Severity.Error, null, "No input provided, stopping."); return(null); } string value; if (options.TryGetValue("verbose", out value) && value != "false") { try { // Enum.TryParse() does not exist before .NET 4 so use Enum.Parse sink.MinSeverity = (Severity)Enum.Parse(typeof(Severity), value); } catch (Exception) { // Docs say OverflowException, but that just sounds wrong sink.MinSeverity = Severity.Verbose; } } var c = new Compiler(sink, prelude, inputFiles); return(ProcessArguments(c, options) ? c : null); }
[STAThread] // Required by ICSharpCode.TextEditor public static void Main(string[] args) { BMultiMap <string, string> options = new BMultiMap <string, string>(); var argList = args.ToList(); UG.ProcessCommandLineArguments(argList, options, "", ShortOptions, TwoArgOptions); if (!options.ContainsKey("nologo")) { Console.WriteLine("LeMP macro compiler (pre-alpha)"); } string _; if (options.TryGetValue("help", out _) || options.TryGetValue("?", out _)) { ShowHelp(KnownOptions.OrderBy(p => p.Key)); return; } if (options.ContainsKey("editor")) { Console.WriteLine("Starting editor..."); System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); System.Windows.Forms.Application.Run(new TextEditor.LempDemoForm()); return; } Severity minSeverity = Severity.Note; #if DEBUG minSeverity = Severity.Debug; #endif var filter = new SeverityMessageFilter(MessageSink.Console, minSeverity); Compiler c = ProcessArguments(options, filter, typeof(Macros), argList); Compiler.WarnAboutUnknownOptions(options, MessageSink.Console, KnownOptions); if (c != null) { c.AddMacros(typeof(global::LeMP.StandardMacros).Assembly); c.MacroProcessor.PreOpenedNamespaces.Add(GSymbol.Get("LeMP.Prelude")); c.MacroProcessor.PreOpenedNamespaces.Add(GSymbol.Get("LeMP")); using (LNode.PushPrinter(Ecs.EcsNodePrinter.PrintPlainCSharp)) c.Run(); } else if (args.Length == 0) { ShowHelp(KnownOptions.OrderBy(p => p.Key)); Console.WriteLine(); Console.WriteLine("LeMP started without arguments. Starting editor (--editor)"); var thread = new ThreadEx(() => { System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.Run(new TextEditor.LempDemoForm()); }); thread.Thread.SetApartmentState(ApartmentState.STA); thread.Start(); Console.WriteLine("Press Enter to run unit tests. Using the editor? Keep the terminal open."); Console.ReadLine(); RunTests.Run(new Loyc.Syntax.Lexing.TokenTests()); RunTests.Run(new Loyc.Syntax.Les.LesLexerTests()); RunTests.Run(new Loyc.Syntax.Les.LesParserTests()); RunTests.Run(new Loyc.Syntax.Les.LesPrinterTests()); RunLeMPTests(); Ecs.Program.RunEcsTests(); } }
public static Compiler ProcessArguments(BMultiMap<string, string> options, SeverityMessageFilter sink, Type prelude, List<string> inputFiles) { if (inputFiles.Count == 0) { sink.Write(Severity.Error, null, "No input provided, stopping."); return null; } Compiler c = new Compiler(sink, prelude); c.Files = new List<InputOutput>(OpenSourceFiles(sink, inputFiles)); return ProcessArguments(c, options) ? c : null; }