/// <summary> /// Pops a set of tokens from the token queue until the occurence /// is satisfied /// </summary> /// <param name="tokens">The token list to pop from</param> public void PopFrom(Queue <TokenBase> tokens) { while (tokens.Count != 0 && !( TokenTypeOne.IsAssignableFrom(tokens.Peek().GetType()) || TokenTypeTwo.IsAssignableFrom(tokens.Peek().GetType()) ) ) { tokens.Dequeue(); } }
/// <summary> /// Checks if the list of tokens is valid for the occurence /// </summary> /// <param name="tokens">The tokens</param> /// <returns>True if valid, otherwise false</returns> public bool IsValidFor(Queue <TokenBase> tokens) { bool valid = tokens.Count != 0 && ( TokenTypeOne.IsAssignableFrom(tokens.Peek().GetType()) || TokenTypeTwo.IsAssignableFrom(tokens.Peek().GetType()) ); if (valid) { tokens.Dequeue(); } return(valid); }