@Requires("lookahead >= 0")
  public Token peek(int lookahead) {
    ArrayDeque<Token> tmp = new ArrayDeque<Token>();
    for (int i = 0; i <= lookahead; ++i) {
      if (hasNext()) {
        tmp.push(next());
      }
    }
    Token token = tmp.peek();
    while (!tmp.isEmpty()) {
      pushback(tmp.pop());
    }
    return token;
  }
@ Requires ( "lookahead >= 0" ) public Token peek ( int lookahead ) { ArrayDeque < Token > tmp = new ArrayDeque < Token > ( ) ; for ( int i = 0 ; i <= lookahead ; ++ i ) { if ( hasNext ( ) ) { tmp . push ( next ( ) ) ; } } Token token = tmp . peek ( ) ; while ( ! tmp . isEmpty ( ) ) { pushback ( tmp . pop ( ) ) ; } return token ; }
Returns the next {@code lookahead}-th token, or {@code null} if
there is none. Look-ahead tokens are counted from 0.