A simple version of Compiler that takes a single input and produces a StringBuilder. Pre-opens LeMP.Prelude namespace.
Наследование: Compiler
Пример #1
0
        public static void Test(string input, string output, IMessageSink sink, int maxExpand = 0xFFFF, params string[] preOpenedNamespaces)
        {
            var c = new TestCompiler(sink, new UString(input), preOpenedNamespaces);

            c.MaxExpansions = maxExpand;
            c.MacroProcessor.AbortTimeout = TimeSpan.Zero; // never timeout (avoids spawning a new thread)
            c.Run();                                       // uses ParsingService.Default and default LNode.Printer
            Assert.AreEqual(StripExtraWhitespace(output), StripExtraWhitespace(c.Output.ToString()));
        }
Пример #2
0
		public static void Test(string input, string output, IMessageSink sink, int maxExpand = 0xFFFF)
		{
			using (LNode.PushPrinter(new EcsNodePrinter(null, null) { PreferPlainCSharp = true }.Print)) {
				var c = new TestCompiler(sink, new UString(input), "");
				c.MaxExpansions = maxExpand;
				c.MacroProcessor.AbortTimeout = TimeSpan.Zero; // never timeout (avoids spawning a new thread)
				c.Run();
				Assert.AreEqual(StripExtraWhitespace(output), StripExtraWhitespace(c.Output.ToString()));
			}
		}
Пример #3
0
 public static void Test(string input, string output, IMessageSink sink, int maxExpand = 0xFFFF)
 {
     using (LNode.PushPrinter(Ecs.EcsNodePrinter.Printer)) {
         var c = new TestCompiler(sink, new UString(input), "");
         c.MaxExpansions = maxExpand;
         c.MacroProcessor.AbortTimeout = TimeSpan.Zero;                 // never timeout (avoids spawning a new thread)
         c.Run();
         Assert.AreEqual(StripExtraWhitespace(output), StripExtraWhitespace(c.Output.ToString()));
     }
 }
Пример #4
0
        public static void Test(string input, string output, IMessageSink sink, int maxExpand = 0xFFFF, bool plainCS = true)
        {
            ILNodePrinter printer = plainCS ? EcsLanguageService.WithPlainCSharpPrinter : EcsLanguageService.Value;

            using (LNode.SetPrinter(printer))
            {
                var c = new TestCompiler(sink, new UString(input), "");
                c.MaxExpansions = maxExpand;
                c.MacroProcessor.AbortTimeout = TimeSpan.Zero;                 // never timeout (avoids spawning a new thread)
                c.Run();
                Assert.AreEqual(StripExtraWhitespace(output), StripExtraWhitespace(c.Output.ToString()));
            }
        }
Пример #5
0
        private void Test(string input, IParsingService inLang, string expected, IParsingService outLang, int maxExpand = 0xFFFF)
        {
            var lemp       = NewLemp(maxExpand);
            var inputCode  = new RVList <LNode>(inLang.Parse(input, _sink));
            var results    = lemp.ProcessSynchronously(inputCode);
            var expectCode = outLang.Parse(expected, _sink);

            if (!results.SequenceEqual(expectCode))
            {                   // TEST FAILED, print error
                string resultStr = results.Select(n => outLang.Print(n, _sink)).Join("\n");
                Assert.AreEqual(TestCompiler.StripExtraWhitespace(expected),
                                TestCompiler.StripExtraWhitespace(resultStr));
            }
        }
Пример #6
0
 private void Test(string input, string output, int maxExpand = 0xFFFF)
 {
     TestCompiler.Test(input, output, _sink, maxExpand);
 }
Пример #7
0
		public static void Test(string input, string output, IMessageSink sink, int maxExpand = 0xFFFF, bool plainCS = true)
		{
			ILNodePrinter printer = plainCS ? EcsLanguageService.WithPlainCSharpPrinter : EcsLanguageService.Value;
			using (LNode.SetPrinter(printer))
			{
				var c = new TestCompiler(sink, new UString(input), "");
				c.MaxExpansions = maxExpand;
				c.MacroProcessor.AbortTimeout = TimeSpan.Zero; // never timeout (avoids spawning a new thread)
				c.Run();
				Assert.AreEqual(StripExtraWhitespace(output), StripExtraWhitespace(c.Output.ToString()));
			}
		}
Пример #8
0
 private void Test(string input, string output, int maxExpand = 0xFFFF, IParsingService parser = null, ILNodePrinter printer = null, IMessageSink sink = null)
 {
     using (ParsingService.SetDefault(parser ?? Les2LanguageService.Value))
         using (LNode.SetPrinter(printer ?? EcsLanguageService.WithPlainCSharpPrinter))
             TestCompiler.Test(input, output, sink ?? _sink, maxExpand, "LeMP.les2.to.ecs");
 }