def _p_section(self):
        self._p_simple_string('[')
        # The section we start as a list of elements. Each element in the
        # list indicates what sub-section of its preceeding section it
        # refers to.
        #
        # This means that a section is either one of the known text strings
        # or a series of numbers, separated by '.' followed by one of the
        # known text strings OR the string 'MIME'.
        #
        # So, see if we have a list of numbers separated by '.'
        #
        sect_list = []
        try:
            while True:
                sect_list.append(int(self._p_re(_number_re)))
                self._p_simple_string('.')
        except NoMatch:
            pass

        # At this point if the next character is ']' then we are at the
        # end of our subsection list.
        #
        if self._p_simple_string(']', silent = True) is not None:
            return sect_list

        # Now we either have one of our known strings. If sect_list is not
        # empty we may also have the string 'MIME'
        #
        section = None
        section_texts = ['header.fields.not', 'header.fields', 'header',
                         'text']
        if len(sect_list) > 0:
            section_texts.append('mime')
        for st in section_texts:
            section = self._p_simple_string(st, silent = True)
            if section is not None:
                break
        if section is None:
            raise BadSyntax(value = "%s: expected a valid section " \
                            "identifier, one of: %s" % \
                            (self.input[:10], str(section_texts)))

        # If the section is one of 'header.fields.not' or 'header.fields'
        # then we have more parsing to do. We expect a ' ' and then a
        # paren list of astrings which is the 'header' list.
        #
        if section in ('header.fields.not', 'header.fields'):
            self._p_simple_string(' ')
            header_list = self._p_paren_list_of(self._p_astring)
            if len(header_list) == 0:
                raise BadSyntax(value = "section '%s' must be followed by a " \
                                "parenthesized list of one or more " \
                                "headers." % section)
            sect_list.append((section, header_list))
        else:
            sect_list.append(section)

        # and finally we must be followed by ']'
        self._p_simple_string(']')
        return sect_list

    #######################################################################
    #
Fetch the "section" part of a body.
dataset/ETHPy150Open scanner/asimap/asimap/parse.py/IMAPClientCommand._p_section