
    Pik                    0   U d dl mZ d dlZd dlmZmZmZmZmZ d dl	Z	d dl
mZ ddlmZmZmZ eefZded<    ed	 d
D                       Z ed          Zded<    G d d          Z G d d          Z ej        e            ej        e           dS )    )annotationsN)MutableMappingMappingMutableSequenceIteratorIterable)Any   )deprecate_argument_is_iterable_flattenztuple[type, ...]str_typec              #     K   | ]}|V  d S N ).0_s     e/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/pyparsing/results.py	<genexpr>r      s      a    r   slice
NULL_SLICEc                  :    e Zd ZU ded<   dgZdd	Zd
 Zd Zd ZdS )_ParseResultsWithOffsetztuple[ParseResults, int]tupp1ParseResultsp2intreturnNonec                    ||f| _         d S r   r   )selfr   r   s      r   __init__z _ParseResultsWithOffset.__init__   s    .0"Xr   c                    | j         |         S r   r#   r$   is     r   __getitem__z#_ParseResultsWithOffset.__getitem__   s    x{r   c                    | j         S r   r#   r$   s    r   __getstate__z$_ParseResultsWithOffset.__getstate__"   s	    xr   c                     |d         | _         d S Nr   r#   )r$   argss     r   __setstate__z$_ParseResultsWithOffset.__setstate__%   s    7r   N)r   r   r   r   r    r!   )	__name__
__module____qualname____annotations__	__slots__r%   r)   r,   r0   r   r   r   r   r      sj         !!!!I6 6 6 6        r   r   c                     e Zd ZU dZdg dfZded<   ded<   d ed<   d	ed
<   ded<   ded<   ded<   dZ G d de          ZdIdZ	dddde
fdJdZd Ze
fdZd ZdKdZdLdZdKdZdMd!ZdMd"Zd# Zd$ Zd% ZdKd&Zd' ZdNd(Zd) Zd* Zd+ Zd, Zd- ZdOd/ZdOd0Z dPd1Z!dQd2Z"dQd3Z#dRd5Z$d6d7dSd:Z%dTd<Z&dPd=Z'dPd>Z(dUd@Z)dVdQdBZ*dC Z+dD Z,dE Z-dF Z.dG Z/e0dNdPdH            Z1e%Z2	 e&Z3	 e)Z4dS )Wr   a  Structured parse results, to provide multiple means of access to
    the parsed data:

    - as a list (``len(results)``)
    - by list index (``results[0], results[1]``, etc.)
    - by attribute (``results.<results_name>`` - see :class:`ParserElement.set_results_name`)

    Example:

    .. testcode::

       integer = Word(nums)
       date_str = (integer.set_results_name("year") + '/'
                   + integer.set_results_name("month") + '/'
                   + integer.set_results_name("day"))
       # equivalent form:
       # date_str = (integer("year") + '/'
       #             + integer("month") + '/'
       #             + integer("day"))

       # parse_string returns a ParseResults object
       result = date_str.parse_string("1999/12/31")

       def test(s, fn=repr):
           print(f"{s} -> {fn(eval(s))}")

       test("list(result)")
       test("result[0]")
       test("result['month']")
       test("result.day")
       test("'month' in result")
       test("'minutes' in result")
       test("result.dump()", str)

    prints:

    .. testoutput::

       list(result) -> ['1999', '/', '12', '/', '31']
       result[0] -> '1999'
       result['month'] -> '12'
       result.day -> '31'
       'month' in result -> True
       'minutes' in result -> False
       result.dump() -> ['1999', '/', '12', '/', '31']
       - day: '31'
       - month: '12'
       - year: '1999'

    Nr   ztuple[Any, ...]_null_valuesstr_name_parentzset[str]
_all_namesbool_modalz	list[Any]_toklistzdict[str, Any]_tokdict)r9   r:   r;   r=   r>   r?   c                      e Zd ZdZddZdS )ParseResults.Lista9  
        Simple wrapper class to distinguish parsed list results that should be preserved
        as actual Python lists, instead of being converted to :class:`ParseResults`:

        .. testcode::

           import pyparsing as pp
           ppc = pp.common

           LBRACK, RBRACK, LPAR, RPAR = pp.Suppress.using_each("[]()")
           element = pp.Forward()
           item = ppc.integer
           item_list = pp.DelimitedList(element)
           element_list = LBRACK + item_list + RBRACK | LPAR + item_list + RPAR
           element <<= item | element_list

           # add parse action to convert from ParseResults
           # to actual Python collection types
           @element_list.add_parse_action
           def as_python_list(t):
               return pp.ParseResults.List(t.as_list())

           element.run_tests('''
               100
               [2,3,4]
               [[2, 1],3,4]
               [(2, 1),3,4]
               (2,3,4)
               ([2, 3], 4)
               ''', post_parse=lambda s, r: (r[0], type(r[0]))
           )

        prints:

        .. testoutput::
           :options: +NORMALIZE_WHITESPACE


           100
           (100, <class 'int'>)

           [2,3,4]
           ([2, 3, 4], <class 'list'>)

           [[2, 1],3,4]
           ([[2, 1], 3, 4], <class 'list'>)

           [(2, 1),3,4]
           ([[2, 1], 3, 4], <class 'list'>)

           (2,3,4)
           ([2, 3, 4], <class 'list'>)

           ([2, 3], 4)
           ([[2, 3], 4], <class 'list'>)

        (Used internally by :class:`Group` when `aslist=True`.)
        Nc                    |g }t          |t                    s+t          | j         dt	          |          j                   t                              |           S )Nz* may only be constructed with a list, not )
isinstancelist	TypeErrorr1   type__new__)cls	containeds     r   rG   zParseResults.List.__new__   sb     	i.. |iitT]Ogii   <<$$$r   r   )r1   r2   r3   __doc__rG   r   r   r   ListrA   o   s3        9	 9	v		% 		% 		% 		% 		% 		%r   rK   c                   t          |t                    r|S t                              |           }d |_        d |_        t                      |_        |g |_        n^t          |t          t          f          r:t          |t          j                  r|d d          gnt          |          |_        n|g|_        t                      |_        |S r   )rC   r   objectrG   r9   r:   setr;   r>   rD   _generator_typerK   dictr?   )rH   toklistnamekwargsr$   s        r   rG   zParseResults.__new__   s    g|,, 	N~~c""
%%?DMM$!899 	& g|'899#']] MM %IDMr   Tr    r!   c                ^   t          |ddd          }|o|}|  || _        ||dk    rd S  ||t                    rt          |          }|s|h| _        || _        || j        v rd S  ||t          t          f          r|g}|rl ||t                    r&t          t          |j                  d          | |<   n&t          t          |d                   d          | |<   || |         _        d S 	 |d         | |<   d S # t          t          t          f$ r || ur|| |<   Y d S || _        Y d S w xY w)NasListTaslist)new_name r   )r   r=   r   r8   r;   r9   r7   r   rF   r   r   r>   KeyErrorrE   
IndexError)r$   rQ   rR   rV   modalrC   rS   rU   s           r   r%   zParseResults.__init__   sz    $FHdXNNN"F9<42::F:dC   	t99D 	%#fDO
d'''F:g$/00 	 iG 	z'<00 R4\'BR5S5SUVWWT

4\'!*5M5MqQQT
#DJF	" DJJJ)Z0 	" 	" 	"d""$T



!



		"s   1C> > D,!D,+D,c                    t          |t          t          f          r| j        |         S || j        vr| j        |         d         d         S t          d | j        |         D                       S )Nr   c                    g | ]
}|d          S )r   r   r   vs     r   
<listcomp>z,ParseResults.__getitem__.<locals>.<listcomp>  s    <<<aQqT<<<r   )rC   r   r   r>   r;   r?   r   r'   s     r   r)   zParseResults.__getitem__   sm    a#u&& 	$=##DO##=#B'**<<4=+;<<<===r   c                    ||t                     r<| j                            |t                                |gz   | j        |<   |d         }n\ ||t          t
          f          r|| j        |<   |}n7| j                            |g           t          |d          gz   | j        |<   |} ||t                    r	| |_        d S d S r.   )	r   r?   getrD   r   r   r>   r   r:   )r$   kr`   rC   subs        r   __setitem__zParseResults.__setitem__  s    :a011 
	#}00DFF;;qcADM!A$CCZC<(( 	 DM!CC#}00B77'1--;  DM! C:c<(( 	CKKK	 	r   c           	     \   t          |t          t          f          s
| j        |= d S |t          k    r| j                                         d S t          | j                  }| j        |= t          |t                    r|dk     r||z  }t          ||dz             }t          t          |
                    |                     }|                                 | j                                        D ]9}|D ]4}t          |          D ]"\  }\  }}t          ||||k    z
            ||<   #5:d S )Nr   r
   )rC   r   r   r?   r   r>   clearlenrD   rangeindicesreversevalues	enumerater   )	r$   r(   mylenremovedoccurrencesjrd   valuepositions	            r   __delitem__zParseResults.__delitem__  sM   !c5\** 	a F 
??M!!!FDM""M! a 	 1uuU
aQAuaii../00=//11 	 	K  ,5k,B,B  (A(x%<x8a<8& &KNN	 	r   c                    || j         v S r   r?   )r$   rd   s     r   __contains__zParseResults.__contains__2  s    DM!!r   r   c                *    t          | j                  S r   )ri   r>   r+   s    r   __len__zParseResults.__len__5  s    4=!!!r   c                "    | j         p| j          S r   )r>   r?   r+   s    r   __bool__zParseResults.__bool__8  s    6777r   r   c                *    t          | j                  S r   iterr>   r+   s    r   __iter__zParseResults.__iter__;      DM"""r   c                <    t          | j        d d d                   S )Nr]   r~   r+   s    r   __reversed__zParseResults.__reversed__>  s    DM$$B$'(((r   c                *    t          | j                  S r   )r   r?   r+   s    r   keyszParseResults.keysA  r   r   c                D      fd                                  D             S )Nc              3  (   K   | ]}|         V  d S r   r   r   rd   r$   s     r   r   z&ParseResults.values.<locals>.<genexpr>E  s'      --AQ------r   r   r+   s   `r   rm   zParseResults.valuesD  s%    --------r   c                D      fd                                  D             S )Nc              3  ,   K   | ]}||         fV  d S r   r   r   s     r   r   z%ParseResults.items.<locals>.<genexpr>H  s+      22DG222222r   r   r+   s   `r   itemszParseResults.itemsG  s%    2222diikk2222r   c                    | j           S )z
        Since ``keys()`` returns an iterator, this method is helpful in bypassing
        code that looks for the existence of any defined results names.rw   r+   s    r   haskeyszParseResults.haskeysJ  s     }$$$r   c                2   |sdg}|                                 D ]'\  }}|dk    r|d         |f}t          d|          t          |d         t                    st	          |          dk    s
|d         | v r|d         }| |         }| |= |S |d         }|S )a  
        Removes and returns item at specified index (default= ``last``).
        Supports both ``list`` and ``dict`` semantics for ``pop()``. If
        passed no argument or an integer argument, it will use ``list``
        semantics and pop tokens from the list of parsed tokens. If passed
        a non-integer argument (most likely a string), it will use ``dict``
        semantics and pop the corresponding value from any defined results
        names. A second default return value argument is supported, just as in
        ``dict.pop()``.

        Example:

        .. doctest::

           >>> numlist = Word(nums)[...]
           >>> print(numlist.parse_string("0 123 321"))
           ['0', '123', '321']

           >>> def remove_first(tokens):
           ...     tokens.pop(0)
           ...
           >>> numlist.add_parse_action(remove_first)
           [W:(0-9)]...
           >>> print(numlist.parse_string("0 123 321"))
           ['123', '321']

           >>> label = Word(alphas)
           >>> patt = label("LABEL") + Word(nums)[1, ...]
           >>> print(patt.parse_string("AAB 123 321").dump())
           ['AAB', '123', '321']
           - LABEL: 'AAB'

           >>> # Use pop() in a parse action to remove named result
           >>> # (note that corresponding value is not
           >>> # removed from list form of results)
           >>> def remove_LABEL(tokens):
           ...     tokens.pop("LABEL")
           ...     return tokens
           ...
           >>> patt.add_parse_action(remove_LABEL)
           {W:(A-Za-z) {W:(0-9)}...}
           >>> print(patt.parse_string("AAB 123 321").dump())
           ['AAB', '123', '321']

        r]   defaultr   z)pop() got an unexpected keyword argument r
   )r   rE   rC   r   ri   )r$   r/   rS   rd   r`   indexretdefaultvalues           r   popzParseResults.popP  s    \  	4DLLNN 	S 	SDAqI~~Q| QA Q QRRRd1gs## 	 s4yyA~~aDGEu+CUJ7Lr   c                    || v r| |         S |S )as  
        Returns named result matching the given key, or if there is no
        such name, then returns the given ``default_value`` or ``None`` if no
        ``default_value`` is specified.

        Similar to ``dict.get()``.

        Example:

        .. doctest::

           >>> integer = Word(nums)
           >>> date_str = integer("year") + '/' + integer("month") + '/' + integer("day")

           >>> result = date_str.parse_string("1999/12/31")
           >>> result.get("year")
           '1999'
           >>> result.get("hour", "not specified")
           'not specified'
           >>> result.get("hour")

        r   )r$   keydefault_values      r   rc   zParseResults.get  s    . $;;9  r   c                    | j                             ||           | j                                        D ]4}t	          |          D ]"\  }\  }}t          ||||k    z             ||<   #5dS )a  
        Inserts new element at location index in the list of parsed tokens.

        Similar to ``list.insert()``.

        Example:

        .. doctest::

           >>> numlist = Word(nums)[...]
           >>> print(numlist.parse_string("0 123 321"))
           ['0', '123', '321']

           >>> # use a parse action to insert the parse location
           >>> # in the front of the parsed results
           >>> def insert_locn(locn, tokens):
           ...     tokens.insert(0, locn)
           ...
           >>> numlist.add_parse_action(insert_locn)
           [W:(0-9)]...
           >>> print(numlist.parse_string("0 123 321"))
           [0, '0', '123', '321']

        N)r>   insertr?   rm   rn   r   )r$   r   
ins_stringrq   rd   rs   rt   s          r   r   zParseResults.insert  s    2 	UJ///=//11 	 	K(1+(>(>  $$E8!88x%'78" "A	 	r   c                :    | j                             |           dS )a  
        Add single element to end of ``ParseResults`` list of elements.

        Example:

        .. doctest::

           >>> numlist = Word(nums)[...]
           >>> print(numlist.parse_string("0 123 321"))
           ['0', '123', '321']

           >>> # use a parse action to compute the sum of the parsed integers,
           >>> # and add it to the end
           >>> def append_sum(tokens):
           ...     tokens.append(sum(map(int, tokens)))
           ...
           >>> numlist.add_parse_action(append_sum)
           [W:(0-9)]...
           >>> print(numlist.parse_string("0 123 321"))
           ['0', '123', '321', 444]
        N)r>   append)r$   items     r   r   zParseResults.append  s     , 	T"""""r   c                    t          |t                    r|                     |           dS | j                            |           dS )as  
        Add sequence of elements to end of :class:`ParseResults` list of elements.

        Example:

        .. testcode::

           patt = Word(alphas)[1, ...]

           # use a parse action to append the reverse of the matched strings,
           # to make a palindrome
           def make_palindrome(tokens):
               tokens.extend(reversed([t[::-1] for t in tokens]))
               return ''.join(tokens)

           patt.add_parse_action(make_palindrome)
           print(patt.parse_string("lskdj sdlkjf lksd"))

        prints:

        .. testoutput::

           ['lskdjsdlkjflksddsklfjkldsjdksl']
        N)rC   r   __iadd__r>   extend)r$   itemseqs     r   r   zParseResults.extend  sJ    2 g|,, 	*MM'"""""M  )))))r   c                L    | j         dd= | j                                         dS )z7
        Clear all elements and results names.
        N)r>   r?   rh   r+   s    r   rh   zParseResults.clear  s,     M!!!r   c                ~    	 | |         S # t           $ r( |                    d          rt          |          Y dS w xY w)N__rX   )rY   
startswithAttributeError)r$   rR   s     r   __getattr__zParseResults.__getattr__  sU    	: 	 	 	t$$ +$T***22	s   
 .<<otherc                8    |                                  }||z  }|S r   )copy)r$   r   r   s      r   __add__zParseResults.__add__  s    iikku
r   c                ^   |s| S |j         rut          | j                  fd|j                                         }fd|D             }|D ]2\  }}|| |<   t	          |d         t
                    r| |d         _        3| xj        |j        z  c_        | xj        |j        z  c_        | S )Nc                    | dk     rn| z   S r.   r   )aoffsets    r   <lambda>z'ParseResults.__iadd__.<locals>.<lambda>  s    AEE&&q6z r   c                n    g | ]1\  }}|D ])}|t          |d           |d                             f*2S )r   r
   )r   )r   rd   vlistr`   	addoffsets       r   ra   z)ParseResults.__iadd__.<locals>.<listcomp>  sd       Au   +AaD))AaD//BBC   r   r   )r?   ri   r>   r   rC   r   r:   r;   )r$   r   
otheritemsotherdictitemsrd   r`   r   r   s         @@r   r   zParseResults.__iadd__  s     	K> 	(''FAAAAI--//J    *  N
 ' ( (1QadL11 (#'AaDL'5++r   c                j    t          |t                    r|dk    r|                                 S || z   S r.   )rC   r   r   )r$   r   s     r   __radd__zParseResults.__radd__+  s6    eS!! 	 eqjj99;; 4<r   c                j    t          |           j         d| j        d|                                  dS )N(, ))rF   r1   r>   as_dictr+   s    r   __repr__zParseResults.__repr__3  s4    t**%LLLL4<<>>LLLLr   c                V    dd                     d | j        D                       z   dz   S )N[r   c                t    g | ]5}t          |t                    rt          |          nt          |          6S r   )rC   r   r8   repr)r   r(   s     r   ra   z(ParseResults.__str__.<locals>.<listcomp>:  sG        )L99FCFFFtAww  r   ])joinr>   r+   s    r   __str__zParseResults.__str__6  sH    ii !]    		
r   rX   c                    g }| j         D ]j}|r|r|                    |           t          |t                    r||                                z  }H|                    t          |                     k|S r   )r>   r   rC   r   _asStringListr8   )r$   sepoutr   s       r   r   zParseResults._asStringListB  s    M 	& 	&D  s  

3$-- &t))+++

3t99%%%%
r   F)flattenr   rD   c               J    |rg t          |           S d | j        D             S )a  
        Returns the parse results as a nested list of matching tokens, all converted to strings.
        If ``flatten`` is True, all the nesting levels in the returned list are collapsed.

        Example:

        .. doctest::

           >>> patt = Word(alphas)[1, ...]
           >>> result = patt.parse_string("sldkj lsdkj sldkj")
           >>> # even though the result prints in string-like form,
           >>> # it is actually a pyparsing ParseResults
           >>> type(result)
           <class 'pyparsing.results.ParseResults'>
           >>> print(result)
           ['sldkj', 'lsdkj', 'sldkj']

        .. doctest::

           >>> # Use as_list() to create an actual list
           >>> result_list = result.as_list()
           >>> type(result_list)
           <class 'list'>
           >>> print(result_list)
           ['sldkj', 'lsdkj', 'sldkj']

        .. versionchanged:: 3.2.0
           New ``flatten`` argument.
        c                d    g | ]-}t          |t                    r|                                n|.S r   )rC   r   as_list)r   ress     r   ra   z(ParseResults.as_list.<locals>.<listcomp>o  sC        ",C!>!>GC  r   )r   r>   )r$   r   s     r   r   zParseResults.as_listM  s@    >  	$Xd^^$$ =   r   rP   c                h    fdt          fd|                                 D                       S )ac  
        Returns the named parse results as a nested dictionary.

        Example:

        .. doctest::

           >>> integer = pp.Word(pp.nums)
           >>> date_str = integer("year") + '/' + integer("month") + '/' + integer("day")

           >>> result = date_str.parse_string('1999/12/31')
           >>> type(result)
           <class 'pyparsing.results.ParseResults'>
           >>> result
           ParseResults(['1999', '/', '12', '/', '31'], {'year': '1999', 'month': '12', 'day': '31'})

           >>> result_dict = result.as_dict()
           >>> type(result_dict)
           <class 'dict'>
           >>> result_dict
           {'year': '1999', 'month': '12', 'day': '31'}

           >>> # even though a ParseResults supports dict-like access,
           >>> # sometime you just need to have a dict
           >>> import json
           >>> print(json.dumps(result))
           Traceback (most recent call last):
           TypeError: Object of type ParseResults is not JSON serializable
           >>> print(json.dumps(result.as_dict()))
           {"year": "1999", "month": "12", "day": "31"}
        c                    t          | t                    r6|                                 r|                                 nfd| D             S | S )Nc                &    g | ]} |          S r   r   )r   r`   to_items     r   ra   z9ParseResults.as_dict.<locals>.to_item.<locals>.<listcomp>  s!    ;T;T;T1GGAJJ;T;T;Tr   )rC   r   r   r   )objr   s    r   r   z%ParseResults.as_dict.<locals>.to_item  sO    #|,, (+Ts{{}}};T;T;T;TPS;T;T;TT
r   c              3  8   K   | ]\  }}| |          fV  d S r   r   )r   rd   r`   r   s      r   r   z'ParseResults.as_dict.<locals>.<genexpr>  s3      ==1Q

O======r   )rP   r   )r$   r   s    @r   r   zParseResults.as_dictt  sJ    B	 	 	 	 	 ====

======r   c                    t          | j                  }| j                                        |_        | j        |_        |xj        | j        z  c_        | j        |_        |S )a  
        Returns a new shallow copy of a :class:`ParseResults` object.
        :class:`ParseResults` items contained within the source are
        shared with the copy. Use :meth:`ParseResults.deepcopy` to
        create a copy with its own separate content values.
        )r   r>   r?   r   r:   r;   r9   )r$   r   s     r   r   zParseResults.copy  sQ     4=))}))++l$/)J	
r   c                   |                                  }t          | j                  D ]\  }}t          |t                    r|                                |j        |<   8t          |t          t          f          rUt          |t                    rj t          |                      x|j        |<   }|
                                D ]3\  }}t          |t                    r|                                n|||<   4t          |t                    r* t          |          d |D                       |j        |<   |S )zm
        Returns a new deep copy of a :class:`ParseResults` object.

        .. versionadded:: 3.1.0
        c              3  l   K   | ]/}t          |t                    r|                                n|V  0d S r   )rC   r   deepcopyr_   s     r   r   z(ParseResults.deepcopy.<locals>.<genexpr>  sN       , ,KLJq,$?$?FAJJLLLQ, , , , , ,r   )r   rn   r>   rC   r   r   r8   bytesr   rF   r   r   )r$   r   r(   r   destrd   r`   s          r   r   zParseResults.deepcopy  s8    iikk.. 	 	FAs#|,, "%,,..QC#u.. 	C00 )2c4Q$IIKK Q QDAq.8L.I.IPajjlllqDGGQC** "+$s)) , ,PS, , , # #Q 
r   
str | Nonec                     j         r j         S  j        r< j        }|j                                        }t	           fd|D             d          S t                     dk    rt           j                  dk    rtt	          t           j                                                            d         d         dv r3t	          t           j                                                            S dS )aG  
        Returns the results name for this token expression.

        Useful when several different expressions might match
        at a particular location.

        Example:

        .. testcode::

           integer = Word(nums)
           ssn_expr = Regex(r"\d\d\d-\d\d-\d\d\d\d")
           house_number_expr = Suppress('#') + Word(nums, alphanums)
           user_data = (Group(house_number_expr)("house_number")
                       | Group(ssn_expr)("ssn")
                       | Group(integer)("age"))
           user_info = user_data[1, ...]

           result = user_info.parse_string("22 111-22-3333 #221B")
           for item in result:
               print(item.get_name(), ':', item[0])

        prints:

        .. testoutput::

           age : 22
           ssn : 111-22-3333
           house_number : 221B

        c              3  :   K   | ]\  }}|D ]\  }}|u 	|V  d S r   r   )r   rd   r   r`   locr$   s        r   r   z(ParseResults.get_name.<locals>.<genexpr>  sS         5"'  3Dyy  !yyyy	 r   Nr
   r   )r   r]   )	r9   r:   r?   r   nextri   r   rm   r   )r$   parparent_tokdict_itemss   `  r   get_namezParseResults.get_name  s    @ : 	:\ 	 $C#&<#5#5#7#7    $8      IINNDM""a''T$-..00112215a8GCCT]//11223334r   r   c                   g }d}|                     |r$|t          |                                           z   nd           |sd                    |          S |                                 rt          d |                                 D                       }|D ]\  }}	|r|                     |           |                     | d|z   d| d           t          |	t                    s#|                     t          |	                     t|	s#|                     t          |	                     |                     |	
                    ||||dz                        t          d	 | D                       sd                    |          S | }	d}
d}t          |	          D ]\  }}t          |t                    rM|
                    ||||dz             }|                     | | |
|z   d
| d| | |
|dz   z   | 
           g|                     | | |
|z   d
| d| | |
|dz   z   | 
           d                    |          S )as  
        Diagnostic method for listing out the contents of
        a :class:`ParseResults`. Accepts an optional ``indent`` argument so
        that this string can be embedded in a nested display of other data.

        Example:

        .. testcode::

           integer = Word(nums)
           date_str = integer("year") + '/' + integer("month") + '/' + integer("day")

           result = date_str.parse_string('1999/12/31')
           print(result.dump())

        prints:

        .. testoutput::

           ['1999', '/', '12', '/', '31']
           - day: '31'
           - month: '12'
           - year: '1999'
        
rX   c              3  >   K   | ]\  }}t          |          |fV  d S r   )r8   )r   rd   r`   s      r   r   z$ParseResults.dump.<locals>.<genexpr>  s0      @@41aCFFA;@@@@@@r   z  z- z: r
   )indentfullinclude_list_depthc              3  @   K   | ]}t          |t                    V  d S r   )rC   r   )r   vvs     r   r   z$ParseResults.dump.<locals>.<genexpr>/  s,      ??B:b,//??????r   r   z]:)r   r8   r   r   r   sortedr   rC   r   r   dumpanyrn   )r$   r   r   r   r   r   NLr   rd   r`   incrnlr(   r   vv_dumps                  r   r   zParseResults.dump  s   2 

<G6C////RHHH 	 773<<<<>> 	@@4::<<@@@@@E  1 #JJrNNN

f>tf}>>>>>???!!\22 JJtAww''' JJs1vv&&&

FF%!%1%z	       ??$????? 	 773<<q\\ 	 	EAr"l++ ''!!-!A:	 "   

b6b4&=bb1bbbFbDFUVJDWbY`bb    

]6]4&=]]1]]]F]DFUVJDW]Y[]]    wws||r   c                T    t          j         |                                 g|R i | dS )aF  
        Pretty-printer for parsed results as a list, using the
        `pprint <https://docs.python.org/3/library/pprint.html>`_ module.
        Accepts additional positional or keyword args as defined for
        `pprint.pprint <https://docs.python.org/3/library/pprint.html#pprint.pprint>`_ .

        Example:

        .. testcode::

           ident = Word(alphas, alphanums)
           num = Word(nums)
           func = Forward()
           term = ident | num | Group('(' + func + ')')
           func <<= ident + Group(Optional(DelimitedList(term)))
           result = func.parse_string("fna a,b,(fnb c,d,200),100")
           result.pprint(width=40)

        prints:

        .. testoutput::

           ['fna',
            ['a',
             'b',
             ['(', 'fnb', ['c', 'd', '200'], ')'],
             '100']]
        N)pprintr   )r$   r/   rS   s      r   r   zParseResults.pprintG  s2    : 	dllnn6t666v66666r   c                ^    | j         | j                                        d | j        | j        ffS r   )r>   r?   r   r;   r9   r+   s    r   r,   zParseResults.__getstate__g  s4    M""$$
	
 	
r   c                n    |\  | _         \  | _        }}| _        t          |          | _        d | _        d S r   )r>   r?   r9   rN   r;   r:   )r$   stater   inAccumNamess       r   r0   zParseResults.__setstate__r  s5    HMEEsL$*l++r   c                    | j         | j        fS r   )r>   r9   r+   s    r   __getnewargs__zParseResults.__getnewargs__w  s    }dj((r   c                ~    t          t          |                     t          |                                           z   S r   )dirrF   rD   r   r+   s    r   __dir__zParseResults.__dir__z  s)    4::diikk!2!222r   c           	         | g           }|                                 D ]T\  }}t          |t                    r||                     ||          z  }5| | |g|t	          |                    z  }U| | |g|          }|S )z
        Helper classmethod to construct a :class:`ParseResults` from a ``dict``, preserving the
        name-value relations as results names. If an optional ``name`` argument is
        given, a nested :class:`ParseResults` will be returned.
        )rR   )rR   rV   )r   rC   r   	from_dictr   )rH   r   rR   r   rd   r`   s         r   r   zParseResults.from_dict}  s     c"ggKKMM 	@ 	@DAq!W%% @s}}QQ}///ssA3Q|A????#se$'''C
r   )NN)r    r!   )r    r<   )r    r   )r    r   r   )r   r   r    r   )r    r   )r    r8   )rX   )r   r<   r    rD   )r    rP   )r    r   )rX   TTr   )5r1   r2   r3   rJ   r7   r4   r5   rD   rK   rG   rC   r%   r)   rf   ru   rx   rz   r|   r   r   r   rm   r   r   r   rc   r   r   r   rh   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r,   r0   r   r   classmethodr   rU   asDictgetNamer   r   r   r   r   )   s        1 1f &*2rNL2222JJJLLLIE% E% E% E% E%t E% E% E%N   2 ." ." ." ." ."`> > > ,6      :" " " "" " " "8 8 8 8# # # #) ) ) )# # #. . .3 3 3% % % %<  <  < |! ! ! !8  B# # #0* * *<       
   ,       M M M M

 

 

 

	 	 	 	 */ % % % % % %N'> '> '> '>R      .5 5 5 5nL L L L L\7 7 7@	
 	
 	
  
) ) )3 3 3     [  F F G r   r   )
__future__r   collectionscollections.abcr   r   r   r   r   r   typingr	   utilr   r   r   r8   r   r   r4   rF   rO   r   r   r   r   registerr   r   r   <module>r     sy   # " " " " " "                         < < < < < < < < < < "5\ ) ) ) )$2''E$KK
           "s s s s s s s sl   % % %   & & & & &r   