# Path: pdfminer/utils.py
# def choplist(n, seq):
#     """Groups every n elements of the list."""
#     r = []
#     for x in seq:
#         r.append(x)
#         if len(r) == n:
#             yield tuple(r)
#             r = []
#     return


import re
import logging
import unittest
from .utils import choplist
        from io import BytesIO
        from io import BytesIO

        Returns keywords, literals, strings, numbers, arrays and dictionaries.
        Arrays and dictionaries are represented as Python lists and dictionaries.
        """
        while not self.results:
            (pos, token) = self.nexttoken()
            #print((pos,token), (self.curtype, self.curstack))
            if isinstance(token, (int, float, bool, bytes, PSLiteral)):
                # normal token
                self.push((pos, token))
            elif token == KEYWORD_ARRAY_BEGIN:
                # begin array
                self.start_type(pos, 'a')
            elif token == KEYWORD_ARRAY_END:
                # end array
                try:
                    self.push(self.end_type('a'))
                except PSTypeError:
                    if STRICT:
                        raise
            elif token == KEYWORD_DICT_BEGIN:
                # begin dictionary
                self.start_type(pos, 'd')
            elif token == KEYWORD_DICT_END:
                # end dictionary
                try:
                    (pos, objs) = self.end_type('d')
                    if len(objs) % 2 != 0:
                        raise PSSyntaxError('Invalid dictionary construct: %r' % (objs,))
                    # construct a Python dictionary.

# Path: pdfminer/utils.py
# def choplist(n, seq):
#     """Groups every n elements of the list."""
#     r = []
#     for x in seq:
#         r.append(x)
#         if len(r) == n:
#             yield tuple(r)
#             r = []
#     return


# Path: pdfminer/psparser.py
import re
import logging
import unittest
from .utils import choplist
        from io import BytesIO
        from io import BytesIO


        Returns keywords, literals, strings, numbers, arrays and dictionaries.
        Arrays and dictionaries are represented as Python lists and dictionaries.
        """
        while not self.results:
            (pos, token) = self.nexttoken()
            #print((pos,token), (self.curtype, self.curstack))
            if isinstance(token, (int, float, bool, bytes, PSLiteral)):
                # normal token
                self.push((pos, token))
            elif token == KEYWORD_ARRAY_BEGIN:
                # begin array
                self.start_type(pos, 'a')
            elif token == KEYWORD_ARRAY_END:
                # end array
                try:
                    self.push(self.end_type('a'))
                except PSTypeError:
                    if STRICT:
                        raise
            elif token == KEYWORD_DICT_BEGIN:
                # begin dictionary
                self.start_type(pos, 'd')
            elif token == KEYWORD_DICT_END:
                # end dictionary
                try:
                    (pos, objs) = self.end_type('d')
                    if len(objs) % 2 != 0:
                        raise PSSyntaxError('Invalid dictionary construct: %r' % (objs,))
                    # construct a Python dictionary.

                    d = dict((literal_name(k), v) for (k, v) in choplist(2, objs) if v is not None)