public static string GenerateNRun(string text) { var parser = TestHelper.Parse(text); var code = new GenCodeVisitor(); parser.root.Visit(code); code.EndProgram(); //code.PrintCommands(); string output = ""; using (MemoryStream ms = new MemoryStream()) { var sw = new StreamWriter(ms); try { Console.SetOut(sw); code.RunProgram(); sw.Flush(); ms.Seek(0, SeekOrigin.Begin); var sr = new StreamReader(ms); output = sr.ReadToEnd().Trim(); } finally { sw.Dispose(); } } return(output); }
public void SmokeTest() { var parser = TestHelper.Parse(@"begin end"); var code = new GenCodeVisitor(); parser.root.Visit(code); code.EndProgram(); //code.PrintCommands(); code.RunProgram(); }