Esempio n. 1
0
 private static void Consume(IEnumerator <Token> tokens, Token.ETokenTypes expected)
 {
     if (!tokens.MoveNext())
     {
         throw new ParseException(string.Format("End of program when expecting '{0}'", expected));
     }
     if (tokens.Current.TokenType != expected)
     {
         throw new ParseException(string.Format("Found token '{0}' when expecting '{1}'", tokens.Current, expected));
     }
 }
Esempio n. 2
0
 private bool TryConsume(Token.ETokenTypes expected)
 {
     return(_tokenEnumerator.HasNext && _tokenEnumerator.Next.TokenType == expected && _tokenEnumerator.MoveNext());
 }