Uses a tiny state machine to parse JVM descriptors. To get useful wrappers
    around the results, use :py:func:`jawa.core.descriptor.method_descriptor`
    or :py:func:`jawa.core.descriptor.field_descriptor`.

def parse_descriptor(descriptor: str) -> list:
    """
    Uses a tiny state machine to parse JVM descriptors. To get useful wrappers
    around the results, use :py:func:`jawa.core.descriptor.method_descriptor`
    or :py:func:`jawa.core.descriptor.field_descriptor`.
    """
    # States:
    #   10 == NORMAL,
    #   20 == OBJECT REFERENCE
    state = 10
    tokens = []
    token = []
    dimensions = 0
    for char in descriptor:
        if state == 10 and char == 'L':
            state = 20
        elif state == 10 and char == '[':
            dimensions += 1
        elif state == 10:
            tokens.append(JVMType(char, dimensions, _HUMAN_NAMES[char]))
            dimensions = 0
        elif state == 20 and char == ';':
            tokens.append(JVMType('L', dimensions, ''.join(token)))
            dimensions = 0
            state = 10
            del token[:]
        elif state == 20:
            token.append(char)
    return tokens