Ejemplo n.º 1
0
        /// <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();
            }
        }
Ejemplo n.º 2
0
		/// <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));
		}
Ejemplo n.º 3
0
        /// <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)));
        }
Ejemplo n.º 4
0
		/// <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();
			}
		}