'Parse a charset. Does not include the surrounding [].'

def parse_charset(self):

    char_list = []
    invert = 0
    if (self.c == '^'):
        invert = 1
        self.next()
    if (self.c == ']'):
        char_list.append(']')
        self.next()
    while ((not self.end) and (self.c != ']')):
        c1 = self.get()
        if ((self.c == '-') and (self.lookahead(1) != ']')):
            self.next()
            c2 = self.get()
            for a in range(ord(c1), (ord(c2) + 1)):
                char_list.append(chr(a))
        else:
            char_list.append(c1)
    chars = ''.join(char_list)
    if invert:
        return AnyBut(chars)
    else:
        return Any(chars)
