Exemple #1
0
 /// <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();
     }
 }
Exemple #2
0
        /// <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);
        }