'Read a raw token from the input stream.'

def __iter__(self):

    self.reset()
    for nextchar in self.string:
        if (self.state == '    '):
            if self.keep:
                self.token += nextchar
            if (nextchar in self.whitespace):
                if (self.token or self.quoted):
                    (yield self.token)
                    self.reset()
            elif (nextchar in self.escape):
                self.escapedstate = 'a'
                self.state = nextchar
            elif (nextchar in self.quotes):
                self.state = nextchar
            else:
                self.token = nextchar
                self.state = 'a'
        elif (self.state in self.quotes):
            self.quoted = True
            if (nextchar == self.state):
                if self.keep:
                    self.token += nextchar
                self.state = 'a'
            elif ((nextchar in self.escape) and (self.state in self.escapedquotes)):
                if self.keep:
                    self.token += nextchar
                self.escapedstate = self.state
                self.state = nextchar
            else:
                self.token += nextchar
        elif (self.state in self.escape):
            if ((self.escapedstate in self.quotes) and (nextchar != self.state) and (nextchar != self.escapedstate) and (not self.keep)):
                self.token += self.state
            self.token += nextchar
            self.state = self.escapedstate
        elif (self.state == 'a'):
            if (nextchar in self.whitespace):
                self.state = '    '
                assert (self.token or self.quoted)
                (yield self.token)
                self.reset()
                if self.keep:
                    (yield nextchar)
            elif (nextchar in self.quotes):
                if self.keep:
                    self.token += nextchar
                self.state = nextchar
            elif (nextchar in self.escape):
                if self.keep:
                    self.token += nextchar
                self.escapedstate = 'a'
                self.state = nextchar
            else:
                self.token += nextchar
        else:
            raise AssertionError('Invalid    state    {!r}!'.format(self.state))
    if ((self.state in self.escape) and (not self.keep)):
        self.token += self.state
    if (self.token or self.quoted):
        (yield self.token)
