<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def next_token(expected_type, data):
 """ Based on the expected next type, consume the next token returning the type found and an updated buffer with the found token removed :param expected_type: :param data: :return: (TokenType, str) tuple where TokenType is the type of the next token expected """

    next_data = copy.copy(data)

    next_type = TokenType.INVALID

    if len(next_data) == 0 or next_data[0] == None:
        next_type = TokenType.END
    elif (expected_type == TokenType.DIGIT or expected_type == TokenType.DIGIT_OR_ZERO) and next_data[0].isalpha():
        next_type = TokenType.LETTER
    elif expected_type == TokenType.LETTER and next_data[0].isdigit():
        next_type = TokenType.DIGIT
    elif expected_type == TokenType.SUFFIX and next_data[0].isdigit():
        next_type = TokenType.SUFFIX_NO
    else:
        if next_data[0] == '.':
            next_type = TokenType.DIGIT_OR_ZERO
        elif next_data[0] == '_':
            next_type = TokenType.SUFFIX
        elif next_data[0] == '-':
            if len(next_data) > 1 and next_data[1] == 'r':
                next_type = TokenType.REVISION_NO
                # Pop leading char off
                next_data = next_data[1:]
            else:
                next_type = TokenType.INVALID

        next_data = next_data[1:]

    if next_type < expected_type:
        if not ((next_type == TokenType.DIGIT_OR_ZERO and expected_type == TokenType.DIGIT) or
                (next_type == TokenType.SUFFIX and expected_type == TokenType.SUFFIX_NO) or
                (next_type == TokenType.DIGIT and expected_type == TokenType.LETTER)):
            next_type = TokenType.INVALID

    return next_type, next_data