def parse_stream_content(content_stream: bytes) -> list:
    """Break down stream content into a list of commands.

    A command is a list made of operands followed by an operator, like [1, 0, 0, 1, 0, 0, 'cm']
    """
    ret = []
    tokens = parse_obj(b'[' + content_stream + b']')
    i = len(tokens) - 1
    section = None
    current = []
    while i >= 0:
        if type(tokens[i]) == str and tokens[i][0:1] != '/':
            if current:
                ret.insert(0, current)
            current = [tokens[i]]
            i -= 1
            continue
        if type(tokens[i]) != str or tokens[i][0:1] == '/':
            current = [tokens[i]] + current
            if i == 0 and current:
                ret.insert(0, current)
            i -= 1
            continue
            i -= 1
        i -= 1
    if current:
        ret.insert(0, current)
    return ret
Break down stream content into a list of commands.

    A command is a list made of operands followed by an operator, like [1, 0, 0, 1, 0, 0, 'cm']
    
pdfsyntax/graphics.py