public void AddCapture(int number, int index, string value)
{
if (!_captures.ContainsKey(number))
{
_captures.Add(number, new Stack<ParenCapture>());
}
var capture = ParenCapture.Pass(number, index, value);
_captures[number].Push(capture);
// In case there are any saved states, we need to associate the capture with all of them. That way, should
// a saved state be backtracted away, it can clear any captures associated with it.
foreach (var savedState in _savedStates)
{
savedState.AddCapture(capture);
}
}