CapturedToken peekWhile(int offsetFromPosition, Predicate<IdlToken> predicate) {
        int position = cursor + offsetFromPosition;
        // If the start position is out of bounds, return the EOF token.
        if (position >= tokens.size()) {
            return tokens.get(tokens.size() - 1);
        }
        CapturedToken token = tokens.get(position);
        while (token.getIdlToken() != IdlToken.EOF && predicate.test(token.getIdlToken())) {
            token = tokens.get(++position);
        }
        return token;
    }
Captures tokens to a stack of token trees.
smithy-syntax/src/main/java/software/amazon/smithy/syntax/CapturingTokenizer.java