Beispiel #1
0
            /// <summary>
            /// Attempts to get a token of the given type.
            /// </summary>
            /// <returns>The result of the search.</returns>
            public TokenResult GetToken()
            {
                TokenResult result = tokenSource.GetToken();

                if (result != null)
                {
                    tokens.Add(result);
                }
                return(result);
            }
Beispiel #2
0
            protected override TokenResult GetNextToken()
            {
                if (index >= tokens.Count)
                {
                    return(null);
                }
                TokenResult result = tokens[index];

                ++index;
                return(result);
            }
Beispiel #3
0
        /// <summary>
        /// Attempts to match the expression item with the values returned by the parser.
        /// </summary>
        /// <param name="attempt">The parser currently iterating over the token source.</param>
        /// <param name="itemName">The name of the token in the outer expression.</param>
        /// <returns>The results of the match.</returns>
        public MatchResult Match(IParseAttempt attempt, string itemName)
        {
            TokenResult tokenResult = attempt.GetToken();
            bool        isMatch     = tokenResult != null && tokenResult.Name == TokenType;
            MatchResult result      = new MatchResult()
            {
                ItemName = itemName,
                IsMatch  = isMatch,
                Context  = tokenResult,
            };

            return(result);
        }
Beispiel #4
0
            protected override TokenResult GetNextToken()
            {
                if (index >= commandText.Length)
                {
                    return(null);
                }
                TokenResult result = registry.ExtractToken(commandText, ref index);

                if (result == null && !String.IsNullOrWhiteSpace(commandText.Substring(index)))
                {
                    throw new SQLGenerationException("Encountered an unknown token type.");
                }
                return(result);
            }
Beispiel #5
0
 /// <summary>
 /// Restores the given token to the front of the token stream.
 /// </summary>
 /// <param name="result">The token to restore.</param>
 public void PutBack(TokenResult result)
 {
     undo.Push(result);
 }
Beispiel #6
0
 /// <summary>
 /// Adds a token to the stream.
 /// </summary>
 /// <param name="result">The token result to add.</param>
 /// <returns>The current token stream.</returns>
 public TokenStream Add(TokenResult result)
 {
     tokens.Add(result);
     return this;
 }
Beispiel #7
0
 /// <summary>
 /// Adds a token to the stream.
 /// </summary>
 /// <param name="result">The token result to add.</param>
 /// <returns>The current token stream.</returns>
 public TokenStream Add(TokenResult result)
 {
     tokens.Add(result);
     return(this);
 }
Beispiel #8
0
 /// <summary>
 /// Restores the given token to the front of the token stream.
 /// </summary>
 /// <param name="result">The token to restore.</param>
 public void PutBack(TokenResult result)
 {
     undo.Push(result);
 }