def getToken(self):
        """
        Get a token from the stream. String values are returned in a form
        where you need to eval() the returned value to get the actual
        string. The return value is (token_type, token_value).

        Multiline string tokenizing is thanks to David Janes (BlogMatrix)

        @return: The next token.
        @rtype: A token tuple.
        """
        if self.pbtokens:
            return self.pbtokens.pop()
        stream = self.stream
        self.comment = None
        token = ''
        tt = EOF
        while True:
            c = self.getChar()
            if not c:
                break
            elif c == '#':
                self.comment = stream.readline()
                self.lineno += 1
                continue
            if c in self.quotes:
                token = c
                quote = c
                tt = STRING
                escaped = False
                multiline = False
                c1 = self.getChar()
                if c1 == quote:
                    c2 = self.getChar()
                    if c2 == quote:
                        multiline = True
                        token += quote
                        token += quote
                    else:
                        self.pbchars.append(c2)
                        self.pbchars.append(c1)
                else:
                    self.pbchars.append(c1)
                while True:
                    c = self.getChar()
                    if not c:
                        break
                    token += c
                    if (c == quote) and not escaped:
                        if not multiline or (len(token) >= 6 and token.endswith(token[:3]) and token[-4] != '\\'):
                            break
                    if c == '\\':
                        escaped = not escaped
                    else:
                        escaped = False
                if not c:
                    raise ConfigFormatError('%s: Unterminated quoted string: %r, %r' % (self.location(), token, c))
                break
            if c in self.whitespace:
                self.lastc = c
                continue
            elif c in self.punct:
                token = c
                tt = c
                if (self.lastc == ']') or (self.lastc in self.identchars):
                    if c == '[':
                        tt = LBRACK2
                    elif c == '(':
                        tt = LPAREN2
                break
            elif c in self.digits:
                token = c
                tt = NUMBER
                in_exponent=False
                while True:
                    c = self.getChar()
                    if not c:
                        break
                    if c in self.digits:
                        token += c
                    elif (c == '.') and token.find('.') < 0 and not in_exponent:
                        token += c
                    elif (c == '-') and token.find('-') < 0 and in_exponent:
                        token += c
                    elif (c in 'eE') and token.find('e') < 0 and\
                         token.find('E') < 0:
                        token += c
                        in_exponent = True
                    else:
                        if c and (c not in self.whitespace):
                            self.pbchars.append(c)
                        break
                break
            elif c in self.wordchars:
                token = c
                tt = WORD
                c = self.getChar()
                while c and (c in self.identchars):
                    token += c
                    c = self.getChar()
                if c: # and c not in self.whitespace:
                    self.pbchars.append(c)
                if token == "True":
                    tt = TRUE
                elif token == "False":
                    tt = FALSE
                elif token == "None":
                    tt = NONE
                break
            else:
                raise ConfigFormatError('%s: Unexpected character: %r' % (self.location(), c))
        if token:
            self.lastc = token[-1]
        else:
            self.lastc = None
        self.last_token = tt
        return (tt, token)
dataset/ETHPy150Open twitterdev/twitter-for-bigquery/libs/config.py/ConfigReader.getToken/original