private void OnDebugStep(DebugStepEventArgs e) { if (DebugMode && DebugStep != null) { DebugStep(this, e); if (e.Continue != null) { e.Continue.WaitOne(); } } }
public void Run() { Regex input = new Regex(@"\$<", RegexOptions.Compiled); bool matchFound; do { matchFound = false; foreach (Tuple <Regex, string> pair in Pairs) { Match match = pair.Item1.Match(Data); if (match.Success) { DebugStepEventArgs e = new DebugStepEventArgs(); e.OldData = Data; string replacement = pair.Item2; string output = null; int outputLocation = replacement.IndexOf("$>"); if (outputLocation >= 0) { output = replacement.Substring(outputLocation + 2); replacement = replacement.Substring(0, outputLocation); } replacement = input.Replace(replacement, m => IO.ReadLine().Replace("$", "$$")); string result = match.Result(replacement); Data = Data.Substring(0, match.Index) + result + Data.Substring(match.Index + match.Length); if (output != null) { output = input.Replace(output, m => IO.ReadLine().Replace("$", "$$")); IO.WriteLine(match.Result(output)); } e.NewData = Data; e.ReplacementStart = match.Index; e.OldReplacementLength = match.Length; e.NewReplacementLength = result.Length; e.ReplacementPair = pair; OnDebugStep(e); matchFound = true; break; } } }while (matchFound && !Stop); }