/// <summary> /// Ends the lookahead. /// </summary> /// <param name="context">The context.</param> private void EndLookahead(BacktrackContext context) { if (_backtrackStack.Count > 0 && ReferenceEquals(_backtrackStack.Peek(), context)) { _backtrackStack.Pop(); _currentBufferPosition = context.BufferIndex; _tracker.CurrentLocation = context.Location; UpdateCurrentCharacter(); } }
/// <inheritdoc /> public override IDisposable BeginLookahead() { if (Buffer == null) { Buffer = new StringBuilder(); } if (!Buffering) { ExpandBuffer(); Buffering = true; } var context = new BacktrackContext { BufferIndex = _currentBufferPosition, Location = CurrentLocation }; _backtrackStack.Push(context); return new DisposableAction(() => EndLookahead(context)); }
/// <inheritdoc /> public override IDisposable BeginLookahead() { if (Buffer == null) { Buffer = new StringBuilder(); } if (!Buffering) { ExpandBuffer(); Buffering = true; } var context = new BacktrackContext { BufferIndex = _currentBufferPosition, Location = CurrentLocation }; _backtrackStack.Push(context); return(new DisposableAction(() => EndLookahead(context))); }