'Start with a queue of upper-left corners, containing the upper-left
corner of the table itself. Trace out one rectangular cell, remember
it, and add its upper-right and lower-left corners to the queue of
potential upper-left corners of further cells. Process the queue in
top-to-bottom order, keeping track of how much of each text column has
been seen.
We\'ll end up knowing all the row and column boundaries, cell positions
and their dimensions.'

def parse_table(self):

    corners = [(0, 0)]
    while corners:
        (top, left) = corners.pop(0)
        if ((top == self.bottom) or (left == self.right) or (top <= self.done[left])):
            continue
        result = self.scan_cell(top, left)
        if (not result):
            continue
        (bottom, right, rowseps, colseps) = result
        update_dict_of_lists(self.rowseps, rowseps)
        update_dict_of_lists(self.colseps, colseps)
        self.mark_done(top, left, bottom, right)
        cellblock = self.block.get_2D_block((top + 1), (left + 1), bottom, right)
        cellblock.disconnect()
        cellblock.replace(self.double_width_pad_char, '')
        self.cells.append((top, left, bottom, right, cellblock))
        corners.extend([(top, right), (bottom, left)])
        corners.sort()
    if (not self.check_parse_complete()):
        raise TableMarkupError('Malformed    table;    parse    incomplete.')
