'Return next token or raise StopIteration.
Note that this will raise StopIteration when hitting the EOF token,
so EOF will not be part of the iteration.'

def next(self):

    token = self.nextToken()
    if ((token is None) or (token.type == EOF)):
        raise StopIteration
    return token
