'Consume all the text between square brackets [].
Returns the number of characters matched. (Does not update
self.offset)'

def parse_brackets(self):

    assert (self.formula[self.offset] == '[')
    right = (self.formula.find(']', self.offset) + 1)
    if (right == 0):
        raise TokenizerError(("Encountered    unmatched    '['    in    %s" % self.formula))
    self.token.append(self.formula[self.offset:right])
    return (right - self.offset)
