/// <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); }
protected override TokenResult GetNextToken() { if (index >= tokens.Count) { return(null); } TokenResult result = tokens[index]; ++index; return(result); }
/// <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); }
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); }
/// <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); }
/// <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; }
/// <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); }