コード例 #1
0
ファイル: DomTest.cs プロジェクト: Sectoid/haskell-drafts
        public void SillyDeserialization()
        {
            var loader = new DOMLoader();
            var module = loader.load(dataStream1);

            Assert.That(module, Is.Not.Null);
        }
コード例 #2
0
ファイル: DomTest.cs プロジェクト: Sectoid/haskell-drafts
        public void TestParentFill()
        {
            var loader = new DOMLoader();
            var module = loader.load(dataStream1);

            module.walkDFS(x =>
              {
            if(x != module)
              Assert.That(x.Parent, Is.Not.Null);
              });
        }
コード例 #3
0
ファイル: main.cs プロジェクト: Sectoid/haskell-drafts
        public static int Main(string[] args)
        {
            if(args.Length < 1)
            {
              Console.WriteLine("Not enough arguments. Use hsc.exe <file-to-compile> instead.");
              return 1;
            }

            var input = args[0];

            Process parser = new Process();
            parser.StartInfo.UseShellExecute = false;
            parser.StartInfo.FileName = "Parser";
            parser.StartInfo.Arguments = input;
            parser.StartInfo.RedirectStandardOutput = true;
            parser.StartInfo.RedirectStandardError = true;

            parser.Start();
            parser.WaitForExit();

            if(parser.ExitCode != 0)
            {
              // var output = parser.StandardOutput.
              Console.WriteLine("Parser finished with error:");
              string line;
              while ((line = parser.StandardError.ReadLine()) != null)
              {
            Console.WriteLine(line);
              }
              return 1;
            }

            var loader = new DOMLoader();

            var module = loader.load(parser.StandardOutput);

            Console.WriteLine("Successfully parsed! {0}", module);

            return 0;
        }
コード例 #4
0
ファイル: DomTest.cs プロジェクト: Sectoid/haskell-drafts
        public void TestVisitDFS()
        {
            var loader = new DOMLoader();
            var module = loader.load(dataStream1);

            module.visitDFSEnd(new EchoVisitor());
        }
コード例 #5
0
ファイル: DomTest.cs プロジェクト: Sectoid/haskell-drafts
 public void TestSerialize()
 {
     using(var writer = new StringWriter())
     {
       var astObj = new HsModule
     { Location = new SrcLoc { Line = 1, Column = 1 },
       Module = new Module { Name = "Crash" },
       Body = new System.Collections.Generic.List<HsDecl>(new HsDecl [] {
       new HsTypeSig {
         Names = new System.Collections.Generic.List<HsName>( new [] {
             new HsName { Name = "main", }
           } ),
         Type = new HsQualType {
           Context = new HsContext {
             Assertions = new System.Collections.Generic.List<HsAsst>(new [] {
                 new HsAsst {
                   Name = new UnQual { Name = new HsName { Name = "Nya", }, },
                 }
               }),
           },
           Type = new HsTyApp {
             First = new HsTyCon {
               Name = new UnQual { Name = new HsName { Name = "IO", }, },
             },
             Second = new HsTyCon {
               Name = new Special { Value = new HsUnitCon {}, },
             },
           }
         },
       },
     }), };
       var dumper = new DOMLoader();
       dumper.save(writer, astObj);
       Console.WriteLine("Output: {0}", writer.ToString());
     }
 }