static void Main(string[] args) { CoolCore.Language language = null; string pathToGrammarEGT = System.IO.Path.GetFullPath("./../../../compiler/Data/Cool.egt"); string pathToExampleEGT = System.IO.Path.GetFullPath("./../../../compiler/Data/example_arrays.cool"); language = CoolCore.Language.FromFile(pathToGrammarEGT); CoolCore.Compiler.Scanner scanner = new CoolCore.Compiler.Scanner(pathToExampleEGT, language); CoolCore.Compiler.Parser parser = new CoolCore.Compiler.Parser(scanner, language); CoolCore.Compiler.ParseTreeNode tree = parser.CreateParseTree(); CoolCore.Module module = parser.CreateSyntaxTree(); Generator generator = new Generator(module); string path = module.Name + ".exe"; if (File.Exists(path)) File.Delete(path); generator.Compile(path); // // Use ildasm to decompile executable. // if(File.Exists("il.txt")) File.Delete("il.txt"); //Process ildasm = new Process(); //ildasm.StartInfo.FileName = "ildasm.exe"; //ildasm.StartInfo.Arguments = "/OUT=il.txt " + path; //ildasm.Start(); //ildasm.WaitForExit(); //StreamReader il = File.OpenText("il.txt"); //Console.WriteLine(il.ReadToEnd()); //il.Close(); }
private void TestCoolCore() { CoolCore.Language language = null; string pathToGrammarEGT = System.IO.Path.GetFullPath("./../../Data/Cool.egt"); string pathToExampleEGT = System.IO.Path.GetFullPath("./../../Data/example_inits.cool"); language = CoolCore.Language.FromFile(pathToGrammarEGT); CoolCore.Compiler.Scanner scanner = new CoolCore.Compiler.Scanner(pathToExampleEGT, language); CoolCore.Compiler.Parser parser = new CoolCore.Compiler.Parser(scanner, language); CoolCore.Compiler.ParseTreeNode tree = parser.CreateParseTree(); }
private void miCG_Click(object sender, RoutedEventArgs e) { CoolCore.Language language = null; string pathToGrammarEGT = System.IO.Path.GetFullPath("./../../Data/Cool.egt"); string pathToExampleEGT = System.IO.Path.GetFullPath((this.tc.SelectedItem as CoolTabItem).FilePath); language = CoolCore.Language.FromFile(pathToGrammarEGT); CoolCore.Compiler.Scanner scanner = new CoolCore.Compiler.Scanner(pathToExampleEGT, language); CoolCore.Compiler.Parser parser = new CoolCore.Compiler.Parser(scanner, language); CoolCore.Compiler.ParseTreeNode tree = parser.CreateParseTree(); CoolCore.Module module = parser.CreateSyntaxTree(System.IO.Path.GetFileName((this.tc.SelectedItem as CoolTabItem).FilePath)); CoolCore.Compilation.Generator generator = new CoolCore.Compilation.Generator(module); string path = module.Name + ".exe"; if (File.Exists(path)) File.Delete(path); generator.Compile(path); Process ildasm = new Process(); ildasm.StartInfo.FileName = System.IO.Path.GetFullPath("./../../Tools/ildasm.exe"); ildasm.StartInfo.Arguments = "/output=il" + module.Name + ".txt" + " " + path; ildasm.Start(); ildasm.WaitForExit(); Results resForm = new Results(System.IO.Path.GetFullPath("il" + module.Name + ".txt")); resForm.ShowDialog(); }