public override IDisposable BeginLookahead() { BacktrackContext context = new BacktrackContext() { Location = CurrentLocation }; _bookmarks.Push(context); return new DisposableAction(() => { EndLookahead(context); }); }
public override IDisposable BeginLookahead() { // Is this our first lookahead? if (Buffer == null) { // Yes, setup the backtrack buffer Buffer = new StringBuilder(); } if (!Buffering) { // We're not already buffering, so we need to expand the buffer to hold the first character ExpandBuffer(); Buffering = true; } // Mark the position to return to when we backtrack // Use the closures and the "using" statement rather than an explicit stack var context = new BacktrackContext() { BufferIndex = _currentBufferPosition, Location = CurrentLocation }; _backtrackStack.Push(context); return(new DisposableAction(() => { EndLookahead(context); })); }
private void EndLookahead(BacktrackContext context) { if(_bookmarks.Count > 0 && Object.ReferenceEquals(_bookmarks.Peek(), context)) { // Backtrack wasn't cancelled, so pop it _bookmarks.Pop(); // Set the new current location _tracker.CurrentLocation = context.Location; InnerBuffer.Position = context.Location.AbsoluteIndex; } }
private void EndLookahead(BacktrackContext context) { // If the specified context is not the one on the stack, it was popped by a call to DoNotBacktrack if (_backtrackStack.Count > 0 && ReferenceEquals(_backtrackStack.Peek(), context)) { _backtrackStack.Pop(); _currentBufferPosition = context.BufferIndex; _locationTracker.CurrentLocation = context.Location; UpdateCurrentCharacter(); } }
private void EndLookahead(BacktrackContext context) { if (_bookmarks.Count > 0 && ReferenceEquals(_bookmarks.Peek(), context)) { // Backtrack wasn't cancelled, so pop it _bookmarks.Pop(); // Set the new current location _tracker.CurrentLocation = context.Location; InnerBuffer.Position = context.Location.AbsoluteIndex; } }
public override IDisposable BeginLookahead() { BacktrackContext context = new BacktrackContext() { Location = CurrentLocation }; _bookmarks.Push(context); return(new DisposableAction(() => { EndLookahead(context); })); }
public override IDisposable BeginLookahead() { // Is this our first lookahead? if (Buffer == null) { // Yes, setup the backtrack buffer Buffer = new StringBuilder(); } if (!Buffering) { // We're not already buffering, so we need to expand the buffer to hold the first character ExpandBuffer(); Buffering = true; } // Mark the position to return to when we backtrack // Use the closures and the "using" statement rather than an explicit stack BacktrackContext context = new BacktrackContext() { BufferIndex = _currentBufferPosition, Location = CurrentLocation }; _backtrackStack.Push(context); return new DisposableAction(() => { EndLookahead(context); }); }