コード例 #1
0
        /// <summary>
        /// Determines whether the next set of item on the stream matches this finder.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <returns>The token.</returns>
        public Token?IsMatch(TokenizableStream <char> stream)
        {
            if (stream.End())
            {
                return(new Token(
                           stream.Index,
                           stream.Index,
                           TokenType.EOF,
                           string.Empty
                           ));
            }

            stream.TakeSnapshot();

            var Match = IsMatchImpl(stream);

            if (Match == null)
            {
                stream.RollbackSnapshot();
            }
            else
            {
                stream.CommitSnapshot();
            }

            return(Match);
        }
コード例 #2
0
        /// <summary>
        /// Determines whether the next set of item on the stream matches this finder.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <returns>The token.</returns>
        public Token IsMatch(TokenizableStream <char> stream)
        {
            if (stream.End())
            {
                return(new Token
                {
                    StartPosition = stream.Index,
                    EndPosition = stream.Index,
                    TokenType = TokenType.EOF,
                    Value = string.Empty
                });
            }

            stream.TakeSnapshot();

            var Match = IsMatchImpl(stream);

            if (Match == null)
            {
                stream.RollbackSnapshot();
            }
            else
            {
                stream.CommitSnapshot();
            }

            return(Match);
        }