'Yields a list of objects: keywords, literals, strings,
numbers, arrays and dictionaries. Arrays and dictionaries
are represented as Python sequence and dictionaries.'

def nextobject(self, direct=False):

    while (not self.results):
        (pos, token) = self.nexttoken()
        if (isinstance(token, int) or isinstance(token, Decimal) or isinstance(token, bool) or isinstance(token, str) or isinstance(token, PSLiteral)):
            self.push((pos, token))
        elif (token == KEYWORD_ARRAY_BEGIN):
            self.start_type(pos, 'a')
        elif (token == KEYWORD_ARRAY_END):
            try:
                self.push(self.end_type('a'))
            except PSTypeError:
                if STRICT:
                    raise
        elif (token == KEYWORD_DICT_BEGIN):
            self.start_type(pos, 'd')
        elif (token == KEYWORD_DICT_END):
            try:
                (pos, objs) = self.end_type('d')
                if ((len(objs) % 2) != 0):
                    print 'Incomplete    dictionary    construct'
                    objs.append('')
                d = dict(((literal_name(k), v) for (k, v) in choplist(2, objs)))
                self.push((pos, d))
            except PSTypeError:
                if STRICT:
                    raise
        else:
            self.do_keyword(pos, token)
        if self.context:
            continue
        else:
            if direct:
                return self.pop(1)[0]
            self.flush()
    obj = self.results.pop(0)
    return obj
