public static Cmd Debug(Compiler compiler = null) { if (compiler == null) { compiler = new Compiler(); compiler.Compile(new WScript()); } else { StdInOut.ConsoleOut.WriteLine("Debug mode: type n for the next execution or evaluate the code."); } try { compiler.WScript.OnEcho += StdInOut.ConsoleOut.WriteLine; while (true) { StdInOut.ConsoleOut.Write(">"); var code = new StringBuilder(); while (true) { var line = StdInOut.ConsoleIn.ReadLine().Replace("print ", "echo "); if (line.Equals("n")) return Cmd.Next; if (line == null || line == string.Empty) break; code.AppendLine(line); if ((Control.ModifierKeys & Keys.Shift) != 0) break; StdInOut.ConsoleOut.Write(" "); } if (code.Length != 0 && !compiler.AddCode(code.ToString(), true)) StdInOut.ConsoleOut.WriteLine(compiler.Error.Message); } } finally { compiler.WScript.OnEcho -= StdInOut.ConsoleOut.WriteLine; } }
public ScriptRunner(bool debug) { _compiler = new Compiler(); _debug = debug; _compiler.OnError += OnError; this.Results = new List<ScriptResult>(); }