private static void Main(string[] args) { //Assembly node; //using (FileStream fs = new FileStream("sampleinput.txt", FileMode.Open, FileAccess.Read)) //{ // Tokenizer tok = new Tokenizer(); // Parser parser = new Parser("sample", tok, fs); // node = parser.parse(); // node.PrettyPrint(Console.Out); //} //string outFile = "sampleoutput.bc"; Assembly node; try { using (Stream input = new FileStream("sampleinput.txt", FileMode.Open)) { Tokenizer tok = new Tokenizer(); Parser parser = new Parser("sample", tok, input); node = parser.Parse(); //node.PrettyPrint(Console.Out); } string outFile = "sampleoutput.bc"; CodeGenerator gen = new CodeGenerator(node, outFile); gen.Generate(); Debug.WriteLine("running as JIT"); gen.RunJit(); return; } catch (Exception e) { Debug.WriteLine("Error {0} parsing input file.", e.Message); return; } }
private void RunTestExpectValue(string path, int expectedVal) { Assembly node; using (Stream input = new FileStream(path, FileMode.Open)) { Tokenizer tok = new Tokenizer(); Parser parser = new Parser("sample", tok, input); node = parser.Parse(); //node.PrettyPrint(Console.Out); } string outFile = "sampleoutput.bc"; CodeGenerator gen = new CodeGenerator(node, outFile); gen.Generate(); Debug.WriteLine("running as JIT"); int realVal = gen.RunJit(); Assert.Equal(expectedVal, realVal); return; }