def parse(instructions):
    """Return a dict with indices of matching brackets."""
    jumps = {}
    try:
        stack = []
        for i, instruction in enumerate(instructions):
            if instruction == '[':
                stack.append(i)
            elif instruction == ']':
                j = stack.pop()
                jumps[i], jumps[j] = j, i
    except IndexError:
        raise SyntaxError(f'unbalanced brackets at position {i}')
    else:
        return jumps
