コード例 #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();
            }
        }
コード例 #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));
		}
コード例 #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)));
        }
コード例 #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();
			}
		}