HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //snap/certbot/4965/lib/python3.12/site-packages/pyparsing/__pycache__/core.cpython-312.pyc
�

M�h���
�UddlmZddlZddlmZddlZddlZddlmZmZm	Z	m
Z
mZmZm
Z
mZddlmZmZddlmZddlZddlZddlZddlZddlZddlmZddlZddlZddlmZdd	lmZdd
l m!Z!ddl"m#Z#dd
l$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z,m-Z.m/Z/ddl0�ddl1�ddl2m3Z3m4Z4ddl5m6Z6ejnZ8e9e:fZ;de<d<ddlm=Z=Gd�de'�Z>Gd�de'�Z?Gd�de�Z@d�d�ZAd�d�ZBd�d�ZC['						d�d�ZDeDej�ej�j�d��reC�eHeIeJeKeLeMeNeOePeQeRhZSej�ZUeMeVefZWe
e3ee3fZXe
egeYfee3geYfeeVe3geYfee9eVe3geYffZZee9eVde[gdfZ\ee9eVdeYgdfZ]ee9eVeVde3eYgdfZ^ee9eVde[eYgdfZ_ej�ej�zZbd e<d!<e6j�j�Zdd e<d"<e6j�j�Zed e<d#<d$Zfd e<d%<efd&zZgd e<d'<ebefzZhd e<d(<d)j�ej�D�cgc]}|ej�vs�|��c}�Zld e<d*<Gd+�d,e[�Zmdand-e<d.<d/aod�d0�Zp	d�							d�d1�Zq	d�							d�d2�Zr	d�											d�d3�Zs	d�									d�d4�Ztd5�ZuGd6�de�ZvGd7�d8ev�ZwGd9�d:ev�ZxGd;�d<ex�ZyGd=�d>ex�ZzGd?�d@ez�Z{GdA�dBez�Z|ezev_}GdC�dDex�Z~GdE�dFez�ZGdG�dHe~�Z�GdI�dJex�Z�GdK�dLex�Z�GdM�dNe��Z�GdO�dPex�Z�GdQ�dRex�Z�GdS�dTex�Z�GdU�dVex�Z�GdW�dXex�Z�GdY�dZe��Z�Gd[�d\e��Z�Gd]�d^e��Z�Gd_�d`e��Z�Gda�dbe��Z�Gdc�dde��Z�Gde�dfe��Z�Gdg�dhex�Z�Gdi�djev�Z�Gdk�dle��Z�Gdm�dne��Z�Gdo�dpe��Z�Gdq�dre��Z�Gds�dtev�Z�Gdu�dve��Z�Gdw�dxe��Z�Gdy�dze��Z�Gd{�d|e��Z�Gd}�d~e��Z�Gd�d�e��Z�Gd��d�e��Z�Gd��d�e��Z�Gd��d�e��Z�Gd��d�e��Z�Gd��d�e��Z�Gd��d��Z�Gd��d�e��Z�e�Z�Gd��d�e��Z�Gd��d�e��Z�Gd��d�e��Z�Gd��d�e��Z�Gd��d�e��Z�Gd��d�e��Z�Gd��d�e��Z�d�d��Z�e{��j[d��Z�e���j[d��Z�e���j[d��Z�e���j[d��Z�e���j[d��Z�e�d���jgd���Z�e�d���jgd���Z�e�d���jgd���Z�e�e�ze�ze�d�d���zZ�e�e�e�d��ze�z�Z�ezd��e�d���jsd��ze�e�e�e�z���jsd��zezd��zZ�d�d��Z�d�d��Z�d�d��Z�e�e�d��d�z��j[d��Z�e�e�d��d�z��j[d��Z�e�e�d��d�z�j[d��e�d��d�z�j[d��z��j[d��Z�e�e�d�e�j����d�z�j[d��e�d�e�j����d�z�j[dëze�dīd�z�j[d��ze�dūd�z�j[d��z��j[dƫZ�e�d�e�j+�z��j[dȫZ�e�dɫZ�e�dʫZ�eƫ�j��D�cgc]}e�|ev�s�
|��c}Z�d�e<d�<e�Z�e�Z�e�Z�e�Z�e�Z�e�Z�e�Z�e�Z�e/d�eu�Z�e/d�e��Z�e/d�eq�Z�e/d�e��Z�ycc}wcc}w)��)�annotationsN)�deque)�Any�Callable�	Generator�
NamedTuple�Sequence�TextIO�Union�cast)�ABC�abstractmethod)�Enum)�Iterable)�
itemgetter)�wraps)�RLock)�Path�)	�
_FifoCache�_UnboundedCache�__config_flags�_collapse_string_to_ranges�_escape_regex_range_chars�_flatten�LRUMemo�
UnboundedMemo�replaced_by_pep8)�*)�ParseResults�_ParseResultsWithOffset)�pyparsing_unicodeztuple[type, ...]�str_type)�cached_propertyc��eZdZdZdZdZe�D��cgc]}|jd�r�|��c}}Zdj�Z
ycc}}w)�
__compat__aJ
    A cross-version compatibility configuration for pyparsing features that will be
    released in a future version. By setting values in this configuration to True,
    those features can be enabled in prior versions for compatibility development
    and testing.

    - ``collect_all_And_tokens`` - flag to enable fix for Issue #63 that fixes erroneous grouping
      of results names when an :class:`And` expression is nested within an :class:`Or` or :class:`MatchFirst`;
      maintained for compatibility, but setting to ``False`` no longer restores pre-2.3.1
      behavior
    �
compatibilityT�_z(
        collect_all_And_tokens
        N)�__name__�
__module__�__qualname__�__doc__�
_type_desc�collect_all_And_tokens�locals�
startswith�
_all_names�split�_fixed_names)�.0�__s00�~/build/snapcraft-certbot-c9561b03ef7f16aa90eb6754ca5f17a1/parts/certbot/install/lib/python3.12/site-packages/pyparsing/core.pyr&r&PsH��
�!�J�!��%�x�B��r�}�}�S�/A�"�B�J���E�G���Cs
�A�Ar&c�H�eZdZdZdZdZdZdZdZdZ	dZ
dZe�D��cgc]}|jd�r�|��c}}ZeD��cgc]}|jd�s�|��c}}ZeD��cgc]}|jd�s�|��c}}Zedd��Zycc}}wcc}}wcc}}w)	�__diag__�
diagnosticFr(�warn�enable_debugc�H�|jD]}|j|��y�N)�_warning_names�enable)�cls�names  r6�enable_all_warningsz__diag__.enable_all_warningsws#���&�&�	�D��J�J�t��	�N��return�None)r)r*r+r-�)warn_multiple_tokens_in_named_alternation�)warn_ungrouped_named_tokens_in_collection�warn_name_set_on_empty_Forward�!warn_on_parse_using_empty_Forward�warn_on_assignment_to_Forward�%warn_on_multiple_string_args_to_oneof�(warn_on_match_first_with_lshift_operator�!enable_debug_on_named_expressionsr/r0r1r>�_debug_names�classmethodrB)r4r5rAs000r6r8r8gs����J�05�-�05�-�%*�"�(-�%�$)�!�,1�)�/4�,�(-�%�%�x�B��r�}�}�S�/A�"�B�J�'1�M�t�T�_�_�V�5L�d�M�N�%/�S�T�4�?�?�>�3R�D�S�L������C��M��Ss"�B�B�B�B�)B�Br8c�0�eZdZdZdZdZdZdZdZdZ	dZ
d	Zy
)�Diagnosticsa�
    Diagnostic configuration (all default to disabled)

    - ``warn_multiple_tokens_in_named_alternation`` - flag to enable warnings when a results
      name is defined on a :class:`MatchFirst` or :class:`Or` expression with one or more :class:`And` subexpressions
    - ``warn_ungrouped_named_tokens_in_collection`` - flag to enable warnings when a results
      name is defined on a containing expression with ungrouped subexpressions that also
      have results names
    - ``warn_name_set_on_empty_Forward`` - flag to enable warnings when a :class:`Forward` is defined
      with a results name, but has no contents defined
    - ``warn_on_parse_using_empty_Forward`` - flag to enable warnings when a :class:`Forward` is
      defined in a grammar but has never had an expression attached to it
    - ``warn_on_assignment_to_Forward`` - flag to enable warnings when a :class:`Forward` is defined
      but is overwritten by assigning using ``'='`` instead of ``'<<='`` or ``'<<'``
    - ``warn_on_multiple_string_args_to_oneof`` - flag to enable warnings when :class:`one_of` is
      incorrectly called with multiple str arguments
    - ``enable_debug_on_named_expressions`` - flag to auto-enable debug on all subsequent
      calls to :class:`ParserElement.set_name`

    Diagnostics are enabled/disabled by calling :class:`enable_diag` and :class:`disable_diag`.
    All warnings can be enabled by calling :class:`enable_all_warnings`.
    rr������N)r)r*r+r,rGrHrIrJrKrLrMrN�rCr6rRrR}s9���.12�-�01�-�%&�"�()�%�$%�!�,-�)�/0�,�()�%rCrRc�B�tj|j�y)zO
    Enable a global pyparsing diagnostic flag (see :class:`Diagnostics`).
    N)r8r?rA��	diag_enums r6�enable_diagr]�s��
�O�O�I�N�N�#rCc�B�tj|j�y)zP
    Disable a global pyparsing diagnostic flag (see :class:`Diagnostics`).
    N)r8�disablerAr[s r6�disable_diagr`�s��
���Y�^�^�$rCc�,�tj�y)zU
    Enable all global pyparsing diagnostic warnings (see :class:`Diagnostics`).
    N)r8rBrYrCr6rBrB�s��
� � �"rCc��t|�}|D]s}|dzjd�dd\}}}}}|j�jd�s|s|s|r|dk(rd}�M|j�jd�s�m|dvs�rd}�u|S)	Nz::::�:rV�i�	pyparsingT)re�F)�boolr2�lowerr0)	�cmd_line_warn_options�warn_env_varr?�warn_opt�w_action�	w_message�
w_category�w_module�w_lines	         r6�_should_enable_warningsrq�s����,�
�F�)�	��=E��=N�<U�<U��=
�
�1�=�9��)�Z��6��~�~��*�*�3�/��j�H��[�9P��F�
�^�^�
�
(�
(��
-�(�>O�2O��F�	��MrC�PYPARSINGENABLEALLWARNINGS�
ParserElement�str�alphas�
identchars�identbodychars�
0123456789�nums�ABCDEFabcdef�hexnums�	alphanumsrf�
printablesc��eZdZdZdd�Zy)�_ParseActionIndexErrorz�
    Internal wrapper around IndexError so that IndexErrors raised inside
    parse actions aren't misinterpreted as IndexErrors raised inside
    ParserElement parseImpl methods.
    c� �||_||_yr=)�msg�exc)�selfr�r�s   r6�__init__z_ParseActionIndexError.__init__�s�����"%��rCN)r�rtr��
BaseExceptionrErF)r)r*r+r,r�rYrCr6rr�s���&rCrztraceback.StackSummary�_trim_arity_call_linerYc�2������tvr�fd�Sd�d�d}txstjd��datxstdtd|zfa����fd	�}t�d
t�d�j�}||_�j|_|S)zAdecorator to trim function calls to match the arity of the targetc����|�Sr=rY)�s�l�t�funcs   �r6�<lambda>z_trim_arity.<locals>.<lambda>s���t�A�w�rCrF�	rS��limit���rc�F���r�	|�
d�S		�	|�
d�}d�|S#t$rV}�r�|j}tj|d��}|d}|ddgdddtk(}~|r�
�kr
�
dz
�
Yd}~�g�d}~wt
$r }t
d|�jd��d}~wwxYw)NrTrSr�r�z!IndexError raised in parse action)�	TypeError�
__traceback__�	traceback�
extract_tb�pa_call_line_synth�
IndexErrorr�with_traceback)�args�ret�te�tb�frames�
frame_summary�trim_arity_type_error�ie�found_arityr�r��	max_limits        ����r6�wrapperz_trim_arity.<locals>.wrappers�������e�f��&�&��
'��D���L�)��"���
���
����)�)�B�&�1�1�"�A�>�F�$*�2�J�M�&�r��*�+�B�/���3�7I�I�*��,� �9�,�!�Q�J�E�$����
'�,�7��� �.��&�'��
'�s'��	B �AA4�3A4�4B �B�B r)�	__class__)�_single_arg_builtinsr�r��
extract_stackr��getattrr)r,)r�r��	LINE_DIFFr��	func_namer�r�s``   @@r6�_trim_arityr�s�����#�#�&�&�
�E��K��I�2�Y�Y�5L�5L�ST�5U�VX�5Y��+�o�0E�a�0H�J_�`a�Jb�en�Jn�/o�� '�J��j�'�$��*D�*M�*M�N�I� �G���l�l�G�O��NrCc�t����|�|nd�|rtnt�t���t�����fd��}|S)aC
    Function to convert a simple predicate function that returns ``True`` or ``False``
    into a parse action. Can be used in places when a parse action is required
    and :class:`ParserElement.add_condition` cannot be used (such as when adding a condition
    to an operator level in :class:`infix_notation`).

    Optional keyword arguments:

    - ``message`` - define a custom message to be used in the raised exception
    - ``fatal`` - if True, will raise :class:`ParseFatalException` to stop parsing immediately;
      otherwise will raise :class:`ParseException`

    zfailed user-defined conditionc�@��t�|||��s
�||���yr=)rg)r�r�r��exc_type�fnr�s   ���r6�paz%condition_as_parse_action.<locals>.paUs'����B�q�!�Q�K� ��1�a��%�%�!rC)�ParseFatalException�ParseExceptionr�r)r��message�fatalr�r�r�s`   @@r6�condition_as_parse_actionr�AsB��� �(�'�.M�C�&+�"��H�	�R��B�
�2�Y�&��&��IrCc��|rdnd}t|�d|�d|�dt||��dt||��dt||��dd	d
t||��d���
�y)Nrrf�Match z at loc �(�,z)
  z
  �^�>)�print�lineno�col�line)�instring�loc�expr�	cache_hit�
cache_hit_strs     r6�_default_start_debug_actionr�]s{��%�C�"�M�	��o�V�D�6��#��a��s�H�8M�7N�a�PS�TW�Ya�Pb�Oc�d��c�8�$�%�&��Q�s�3��)�*� �*�+�
-�rCc�R�|rdnd}t|�d|�d|j����y)NrrfzMatched z -> )r��as_list)r��startloc�endlocr��toksr�r�s       r6�_default_success_debug_actionr�js-��%�C�"�M�	�]�O�8�D�6��d�l�l�n�-=�
>�?rCc	�b�|rdnd}t|�d|�dt|�j�d|���y)Nrrfr�z	 failed, z	 raised: )r��typer))r�r�r�r�r�r�s      r6�_default_exception_debug_actionr�vs7��%�C�"�M�	�]�O�6�$��y��c��1C�1C�0D�I�c�U�
S�TrCc��y)zG'Do-nothing' debug action, to suppress debugging output during parsing.NrY)r�s r6�null_debug_actionr����rCc���eZdZUdZdZded<dZded<dZd	ed
<ed�d��Z	ed�d��Z
ed
��ZGd�de
�Zd�d�d�Zed��Zej$d��Zd�d�Zd�Zd�d�Z	d�dd�							d�d�Zd�d�d�Zd�d�d�Zd�d�Zd�d�Zd�d�Zd�d�Zd�d�Zd�d �Zd�d�d!�Zd"�Z 	d�	d�d#�Z!ddd$�									d�d%�Z"d�d�d&�Z#e$�Z%iZ&d'ed(<Gd)�d*e'jP�Z)Gd+�d,e*�Z+e+�Z,d*ed-<e$�Z-d.d.gZ.	d�	d�d/�Z/e!Z0ed�d0��Z1dZ2dZ3ed�d1��Z4e	d�dd2�			d�d3��Z5e	d�dd2�					d�d4��Z6	d�dd5�							d�d6�Z7e8ddfde8d7�											d�d8�Z9dd9�d�d:�Z:e8fde8d7�									d�d;�Z;e8dfdd<�							d�d=�Z<d�d>�Z=d�d?�Z>d�d@�Z?d�dA�Z@d�dB�ZAd�dC�ZBd�dD�ZCd�dE�ZDd�dF�ZEd�dG�ZFd�dH�ZGd�dI�ZHd�dJ�ZIdZJdK�ZKd�d�dL�ZLd�dM�ZMd�d�dN�ZNd�d�dO�ZO	d�					d�dP�ZPd�dQ�ZQd�dR�ZR								d�dS�ZSd�d�dT�ZTed�dU��ZUeVd�dV��ZWd�dW�ZXed�dX��ZYeYj$d�dY��ZYd�dZ�ZZd�d[�Z[d�d\�Z\d�d]�Z]d^�Z^d�d�d_�Z_		d�dd5�									d�d`�Z`da�Zadb�Zb	d�dd5�							d�dc�Zc								d�ddddddd�																													d�de�Zd					d�													d�df�Zeeefdge
��Zgeefdhe	��Zheefdie4��Zieefdje5��Zjeefdke6��Zkeefdle1��Zlefdme�Zmefdne�Znefdoe�Zoefdpe�Zpefdqe�Zqefdre�Zrefdse"�Zsefdte7�Ztefdue9�Zuefdve:�Zvefdwe;�ZwefdxeN�ZxefdyeO�ZyefdzeP�Zzefd{eQ�Z{efd|eS�Z|efd}eT�Z}efd~eX�Z~efde`�Zefd�ed�Z�efd�e#�Z�eUZ�y)�rsz)Abstract base level parser element class.z 
	
rt�DEFAULT_WHITE_CHARSFrg�verbose_stacktraceNr��_literalStringClassc�j�|t_tD]}|js�t	|�|_�!y)a�
        Overrides the default whitespace chars

        Example::

            # default whitespace chars are space, <TAB> and newline
            Word(alphas)[1, ...].parse_string("abc def\nghi jkl")  # -> ['abc', 'def', 'ghi', 'jkl']

            # change to just treat newline as significant
            ParserElement.set_default_whitespace_chars(" \t")
            Word(alphas)[1, ...].parse_string("abc def\nghi jkl")  # -> ['abc', 'def']
        N)rsr��_builtin_exprs�copyDefaultWhiteChars�set�
whiteChars)�charsr�s  r6�set_default_whitespace_charsz*ParserElement.set_default_whitespace_chars�s1��-2�
�)�#�	-�D��)�)�"%�e�*���	-rCc��|t_y)al
        Set class to be used for inclusion of string literals into a parser.

        Example::

            # default literal class used is Literal
            integer = Word(nums)
            date_str = integer("year") + '/' + integer("month") + '/' + integer("day")

            date_str.parse_string("1999/12/31")  # -> ['1999', '/', '12', '/', '31']


            # change to Suppress
            ParserElement.inline_literals_using(Suppress)
            date_str = integer("year") + '/' + integer("month") + '/' + integer("day")

            date_str.parse_string("1999/12/31")  # -> ['1999', '12', '31']
        N)rsr�)r@s r6�inline_literals_usingz#ParserElement.inline_literals_using�s��(-0�
�)rCc+�<��K���fd�|D�Ed{���y7��w)z�
        Yields a sequence of ``class(obj, **class_kwargs)`` for obj in seq.

        Example::

            LPAR, RPAR, LBRACE, RBRACE, SEMI = Suppress.using_each("(){};")

        c3�0�K�|]
}�|fi������y�wr=rY)r4�obj�class_kwargsr@s  ��r6�	<genexpr>z+ParserElement.using_each.<locals>.<genexpr>�s�����<��C��,�|�,�<�s�NrY)r@�seqr�s` `r6�
using_eachzParserElement.using_each�s�����=��<�<�<�s���c�,�eZdZUded<ded<ded<y)�ParserElement.DebugActionsz!typing.Optional[DebugStartAction]�	debug_tryz#typing.Optional[DebugSuccessAction]�debug_matchz%typing.Optional[DebugExceptionAction]�
debug_failN)r)r*r+�__annotations__rYrCr6�DebugActionsr��s��4�4�8�8�9�9rCr�c��t�|_d|_d|_d|_d|_||_d|_ttj�|_d|_d|_
d|_t�|_d|_d|_d|_d|_d|_|j+ddd�|_d|_d|_g|_d|_y)NTFrf)�list�parseAction�
failAction�
customName�_defaultName�resultsName�
saveAsList�skipWhitespacer�rsr�r�r��_may_return_empty�keepTabs�ignoreExprs�debug�streamlined�
mayIndexError�errmsg�modalResultsr��debugActions�callPreparse�
callDuringTry�suppress_warnings_�show_in_diagram)r��savelists  r6r�zParserElement.__init__�s���.2�f���<@���#���26��� $���"���"����m�?�?�@���%)��"�!&�����
�04������
� ���!���(*��� ��� �-�-�d�D�$�?��� ���"���57���#��rCc��|jSr=�r��r�s r6�mayReturnEmptyzParserElement.mayReturnEmpty�s���%�%�%rCc��||_yr=r�r��values  r6rzParserElement.mayReturnEmpty��
��!&��rCc�<�|jj|�|S)aZ
        Suppress warnings emitted for a particular diagnostic on this expression.

        Example::

            base = pp.Forward()
            base.suppress_warning(Diagnostics.warn_on_parse_using_empty_Forward)

            # statement would normally raise a warning, but is now suppressed
            print(base.parse_string("x"))

        )r�append)r��warning_types  r6�suppress_warningzParserElement.suppress_warning�s��	
���&�&�|�4��rCc#��K�t|g�}t�}|rM|j�}||vr�|j|�|j	|j��|��|r�Lyy�w)z�General-purpose method to yield all expressions and sub-expressions
        in a grammar. Typically just for internal use.
        N)rr��popleft�add�extend�recurse)r��to_visit�seen�curs    r6�	visit_allzParserElement.visit_all�s^�����$��=���u����"�"�$�C��d�{���H�H�S�M��O�O�C�K�K�M�*��I��s�A$A)�'A)c���tj|�}|jdd|_|jdd|_|jrt	t
j�|_|S)a7
        Make a copy of this :class:`ParserElement`.  Useful for defining
        different parse actions for the same parsing pattern, using copies of
        the original parse element.

        Example::

            integer = Word(nums).set_parse_action(lambda toks: int(toks[0]))
            integerK = integer.copy().add_parse_action(lambda toks: toks[0] * 1024) + Suppress("K")
            integerM = integer.copy().add_parse_action(lambda toks: toks[0] * 1024 * 1024) + Suppress("M")

            print((integerK | integerM | integer)[1, ...].parse_string("5K 100 640K 256M"))

        prints::

            [5120, 100, 655360, 268435456]

        Equivalent form of ``expr.copy()`` is just ``expr()``::

            integerM = integer().add_parse_action(lambda toks: toks[0] * 1024 * 1024) + Suppress("M")
        N)�copyr�r�r�r�rsr�r�)r��cpys  r6rzParserElement.copysU��,�i�i��o���*�*�1�-����*�*�1�-����%�%� ��!B�!B�C�C�N��
rC)�listAllMatchesc�2�|xs|}|j||�S)a�
        Define name for referencing matching tokens as a nested attribute
        of the returned parse results.

        Normally, results names are assigned as you would assign keys in a dict:
        any existing value is overwritten by later values. If it is necessary to
        keep all values captured for a particular results name, call ``set_results_name``
        with ``list_all_matches`` = True.

        NOTE: ``set_results_name`` returns a *copy* of the original :class:`ParserElement` object;
        this is so that the client can define a basic element, such as an
        integer, and reference it in multiple places with different names.

        You can also set results names using the abbreviated syntax,
        ``expr("name")`` in place of ``expr.set_results_name("name")``
        - see :class:`__call__`. If ``list_all_matches`` is required, use
        ``expr("name*")``.

        Example::

            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")
        )�_setResultsName)r�rA�list_all_matchesrs    r6�set_results_namezParserElement.set_results_name+s"��>(�;�+;���#�#�D�.�9�9rCc�|�|�|S|j�}|jd�r|dd}d}||_||_|S)Nrr�T)r�endswithr�r�)r�rAr�newselfs    r6rzParserElement._setResultsNameMsL���<��K��)�)�+���=�=������9�D�#��"���#3�3����rCTc���|r"|j�d�fd�	}�|_||_|St|jd�r|jj|_|S)z�
        Method to invoke the Python pdb debugger when this element is
        about to be parsed. Set ``break_flag`` to ``True`` to enable, ``False`` to
        disable.
        c�.��t��||||�Sr=)�
breakpoint)r�r��
do_actions�callPreParse�_parseMethods    �r6�breakerz(ParserElement.set_break.<locals>.breakeras�����#�H�c�:�|�L�LrC�_originalParseMethod�TT)�_parser+�hasattr)r��
break_flagr*r)s   @r6�	set_breakzParserElement.set_breakXsV�����;�;�L�
M�
,8�G�(�!�D�K����T�[�[�"8�
9��+�+�:�:�D�K��rCc�:�t|�dgk(r|jj�|Std�|D��st	d��|D�cgc]
}t|���c}|jdd|j
d|j
dd��|_|Scc}w)a�
        Define one or more actions to perform when successfully matching parse element definition.

        Parse actions can be called to perform data conversions, do extra validation,
        update external data structures, or enhance or replace the parsed tokens.
        Each parse action ``fn`` is a callable method with 0-3 arguments, called as
        ``fn(s, loc, toks)`` , ``fn(loc, toks)`` , ``fn(toks)`` , or just ``fn()`` , where:

        - ``s``    = the original string being parsed (see note below)
        - ``loc``  = the location of the matching substring
        - ``toks`` = a list of the matched tokens, packaged as a :class:`ParseResults` object

        The parsed tokens are passed to the parse action as ParseResults. They can be
        modified in place using list-style append, extend, and pop operations to update
        the parsed list elements; and with dictionary-style item set and del operations
        to add, update, or remove any named results. If the tokens are modified in place,
        it is not necessary to return them with a return statement.

        Parse actions can also completely replace the given tokens, with another ``ParseResults``
        object, or with some entirely different object (common for parse actions that perform data
        conversions). A convenient way to build a new parse result is to define the values
        using a dict, and then create the return value using :class:`ParseResults.from_dict`.

        If None is passed as the ``fn`` parse action, all previously added parse actions for this
        expression are cleared.

        Optional keyword arguments:

        - ``call_during_try`` = (default= ``False``) indicate if parse action should be run during
          lookaheads and alternate testing. For parse actions that have side effects, it is
          important to only call the parse action once it is determined that it is being
          called as part of a successful parse. For parse actions that perform additional
          validation, then call_during_try should be passed as True, so that the validation
          code is included in the preliminary "try" parses.

        Note: the default parsing behavior is to expand tabs in the input string
        before starting the parsing process.  See :class:`parse_string` for more
        information on parsing strings containing ``<TAB>`` s, and suggested
        methods to maintain a consistent view of the parsed string, the parse
        location, and line and column positions within the parsed string.

        Example::

            # parse dates in the form YYYY/MM/DD

            # use parse action to convert toks from str to int at parse time
            def convert_to_int(toks):
                return int(toks[0])

            # use a parse action to verify that the date is a valid date
            def is_valid_date(instring, loc, toks):
                from datetime import date
                year, month, day = toks[::2]
                try:
                    date(year, month, day)
                except ValueError:
                    raise ParseException(instring, loc, "invalid date given")

            integer = Word(nums)
            date_str = integer + '/' + integer + '/' + integer

            # add parse actions
            integer.set_parse_action(convert_to_int)
            date_str.set_parse_action(is_valid_date)

            # note that integer fields are now ints, not strings
            date_str.run_tests('''
                # successful parse - note that integer fields were converted to ints
                1999/12/31

                # fail - invalid date
                1999/13/31
                ''')
        Nc3�2K�|]}t|����y�wr=)�callable)r4r�s  r6r�z1ParserElement.set_parse_action.<locals>.<genexpr>�s����.�B�8�B�<�.���zparse actions must be callable�call_during_tryrF)r�r��clear�allr�r��getr�r��fns�kwargsr�s    r6�set_parse_actionzParserElement.set_parse_actionls���V��9�������"�"�$��K��.�#�.�.��<�=�=�9<�=�2�{�2��=������#�Z�Z��v�z�z�/�5�A�
������>s�
Bc���|xj|D�cgc]
}t|���c}z
c_|jxs"|jd|jdd��|_|Scc}w)z�
        Add one or more parse actions to expression's list of parse actions. See :class:`set_parse_action`.

        See examples in :class:`copy`.
        r5rF)r�r�rr8r9s    r6�add_parse_actionzParserElement.add_parse_action�s^��	
���s�;��[��_�;�;��!�/�/�
�6�:�:��v�z�z�/�5�A�4
������	<s�A$c
�.�|D]Z}|jjt|t|j	d��t|j	dd������\|jxs"|j	d|j	dd��|_|S)a�Add a boolean predicate function to expression's list of parse actions. See
        :class:`set_parse_action` for function call signatures. Unlike ``set_parse_action``,
        functions passed to ``add_condition`` need to return boolean success/fail of the condition.

        Optional keyword arguments:

        - ``message`` = define a custom message to be used in the raised exception
        - ``fatal`` = if True, will raise ParseFatalException to stop parsing immediately; otherwise will raise
          ParseException
        - ``call_during_try`` = boolean to indicate if this method should be called during internal tryParse calls,
          default=False

        Example::

            integer = Word(nums).set_parse_action(lambda toks: int(toks[0]))
            year_int = integer.copy()
            year_int.add_condition(lambda toks: toks[0] >= 2000, message="Only support years 2000 and later")
            date_str = year_int + '/' + integer + '/' + integer

            result = date_str.parse_string("1999/12/31")  # -> Exception: Only support years 2000 and later (at char 0),
                                                                         (line:1, col:1)
        r�r�F)r�r�r5r)r�r
r�rtr8rgrr9s    r6�
add_conditionzParserElement.add_condition�s���.�	�B����#�#�)����
�
�9� 5�6��v�z�z�'�5�9�:��
�	�"�/�/�
�6�:�:��v�z�z�/�5�A�4
����rCc��||_|S)a
        Define action to perform if parsing fails at this expression.
        Fail acton fn is a callable function that takes the arguments
        ``fn(s, loc, expr, err)`` where:

        - ``s`` = string being parsed
        - ``loc`` = location where expression match was attempted and failed
        - ``expr`` = the parse expression that failed
        - ``err`` = the exception thrown

        The function returns no value.  It may throw :class:`ParseFatalException`
        if it is desired to stop parsing immediately.)r�)r�r�s  r6�set_fail_actionzParserElement.set_fail_action�s������rCc���|js|Sd}|jD�cgc]}|j��}}|}|r&d}|D]}		|||�\}}d}�||k(r	|S|}|r�&|Scc}w#t$rY�4wxYw�NTF)r�r-r�)	r�r�r��
exprsFound�e�ignore_expr_fns�last_loc�	ignore_fn�dummys	         r6�_skipIgnorableszParserElement._skipIgnorabless�������J��
�-1�-=�-=�>��1�8�8�>��>�����J�,�
�	���%.�x��%=�
��U�%)�
��
��h����
��H���
��?��&����s�A �A%�%	A1�0A1c���|jr|j||�}|jr5t|�}|j}||kr|||vr|dz
}||kr|||vr�|S�Nr)r�rKr��lenr�)r�r�r��instrlen�white_charss     r6�preParsezParserElement.preParsesn������&�&�x��5�C�����8�}�H��/�/�K���.�X�c�]�k�%A��q�����.�X�c�]�k�%A��
rCc�
�|gfSr=rY�r�r�r�r's    r6�	parseImplzParserElement.parseImpl&����B�w�rCc��|Sr=rY�r�r�r��	tokenlists    r6�	postParsezParserElement.postParse)s���rCc
��|j}t|�}|s|jr�	|r|jr|j	||�}n|}|}|j
jr|j
j
|||d�|js||k\r	|j|||�\}}	n|j|||�\}}	nd|r|jr|j	||�}n|}|}|js||k\r	|j|||�\}}	n|j|||�\}}	|j|||	�}	t|	|j |j"|j$��}|j&r�|s|j(r�|rk	|j&D]Z}	||||�}	|	��|	|us�t|	|j |j"xrt+|	tt,f�|j$��}�\ni|j&D]Z}	||||�}	|	��|	|us�t|	|j |j"xrt+|	tt,f�|j$��}�\|r6|j
j.r |j
j/|||||d�||fS#t$rt|||j|��wxYw#t$r[}
|j
jr|j
j|||
d�|jr|j|||
��d}
~
wwxYw#t$rt|||j|��wxYw#t$r}
td�}||
�d}
~
wwxYw#t$r;}
|j
jr|j
j||||
d��d}
~
wwxYw#t$r}
td�}||
�d}
~
wwxYw)NF)�asList�modalz exception raised in parse action)r�rNr�r�rQr�r�r�rTr�r�r��	Exceptionr�rYr r�r�r�r�r�
isinstancer�r�)r�r�r�r'r(�	debugging�len_instring�pre_loc�tokens_start�tokens�err�
ret_tokensr��parse_action_excr�s               r6�
_parseNoCachezParserElement._parseNoCache-s����J�J�	��8�}������
��D�$5�$5�"�m�m�H�c�:�G�!�G�&���$�$�.�.��%�%�/�/��,��e�T��%�%��L�)@�X�&*�n�n�X�w�
�&S���V�#'�.�.��7�J�"O�K�C����� 1� 1��-�-��#�6����"�L��!�!�W��%<�T�"&�.�.��7�J�"O�K�C��#�n�n�X�w�
�K���V�����#�v�6��!��D�$�$�T�_�_�D�DU�DU�
�
�����t�/A�/A���"�.�.���<�%'��,�
�%K�F�
"�-�&�
�2J�)5� &� $� 0� 0�'+���(M�$.�v��d�7K�$L�&*�&7�&7�*�J��.�*�*��B�8�!#�H�l�J�!G��
�)�f�J�.F�%1�"� �,�,�#'�?�?�$I� *�6�L�$�3G� H�"&�"3�"3�&�
���� � �,�,��!�!�-�-��l�C��z�5���J����a&�X�,�X�|�T�[�[�RV�W�W�X���
��$�$�/�/��%�%�0�0� �,��c�5���?�?��O�O�H�l�D�#�F���
��$"�T�(��<����d�S�S�T��  *�<�"0�1S�"T�C�"%�+;�;��<��!���(�(�3�3��)�)�4�4�$�l�D�#�u����
��&�8�,�-O�P��!�'7�7��8�s��A*J5�J�(J5�7L�M �
M�M �M �#AM �;
N'�"J2�2J5�5	L�>AL�L�"L>�	M�
M�M�M � 	N$�)6N�N$�'	O�0N>�>O)�raise_fatalr'c��	|j|||��dS#t$r|r�t|||j|��wxYw)N�r'r)r-r�r�r�)r�r�r�rhr's     r6�	try_parsezParserElement.try_parse�sN��	C��;�;�x���;�D�Q�G�G��"�	C��� ��3����T�B�B�	C�s��%>c�X�	|j|||��y#ttf$rYywxYw)NrjTF)rkr�r�rSs    r6�can_parse_nextzParserElement.can_parse_next�s7��	��N�N�8�S�Z�N�@����
�+�	��	�s��)�)zecollections.abc.MutableMapping[tuple[int, Forward, bool], tuple[int, Union[ParseResults, Exception]]]�recursion_memosc�4�eZdZUdZded<dd�Zd	d�Zd	d�Zy)
�ParserElement._CacheTypezm
        Class to be used for packrat and left-recursion cacheing of results
        and exceptions.
        rg�not_in_cachec��yr=rY�r�r�s  r6r8zParserElement._CacheType.get�r�rCc��yr=rYrss  r6r�zParserElement._CacheType.set�r�rCc��yr=rYrs r6r6zParserElement._CacheType.clear�r�rCN�rEz
typing.AnyrD)r)r*r+r,r�r8r�r6rYrCr6�
_CacheTyperp�s��	�
��/�)�$rCrwc�8�eZdZUdZdZded<d	d�Zd
d�Zd
d�Zy)�ParserElement.NullCachez�
        A null cache type for initialization of the packrat_cache class variable.
        If/when enable_packrat() is called, this null cache will be replaced by a
        proper _CacheType class instance.
        Trgrqc��yr=rYrss  r6r8zParserElement.NullCache.get�r�rCc��yr=rYrss  r6r�zParserElement.NullCache.set�r�rCc��yr=rYrs r6r6zParserElement.NullCache.clear�r�rCNrvrD)	r)r*r+r,rqr�r8r�r6rYrCr6�	NullCachery�s��	�"��d�!�/�)�$rCr}�
packrat_cacherc	���d\}}|||||f}tj5tj}|j|�}	|	|jurdtj
|xxdz
cc<	|j
||||�}	|j||	d|	dj�|f�|	cddd�Stj
|xxdz
cc<|jr6|jjr 	|jj|||d��t!|	t"�rG|jr9|jj$r#	|jj%||||	d��|	�|	�t't(t*t,t*f|	�}	|	d|	dj�|	d}
}}|jr8|jj.r"	|jj/|||
||d��||fcddd�S#t$r/}
|j||
j|
j���d}
~
wwxYw#t$rY��.wxYw#t$rY|	�wxYw#t$rY�swxYw#1swYyxYw)N)rrrrT)r�rS)rs�packrat_cache_lockr~r8rq�packrat_cache_statsrgr�r�ParseBaseExceptionr�r�r�r�r�r�r^r]r�r�tuple�intr r�)r�r�r�r'r(�HIT�MISS�lookup�cacher
�pe�loc_�resultr�s              r6�_parseCachezParserElement._parseCache�sa���	��T���#�|�Z�@��
�
-�
-�)	$�!�/�/�E��I�I�f�%�E���*�*�*��1�1�$�7�1�<�7�!� �.�.�x��j�,�W�E��I�I�f�u�Q�x��q�����#�&F�G� �)	$�)	$��1�1�#�6�!�;�6��:�:�$�"3�"3�"=�"=���)�)�3�3�H�c�4�SW�3�X��e�Y�/��z�z�d�&7�&7�&B�&B�!� �-�-�8�8� (�#�t�U�d�9��
 �K�%�K��U�3��c�#9�:�E�B��',�Q�x��q�����%��(�f�f���:�:�$�"3�"3�"?�"?���)�)�5�5�$�d�F�D�&�D�6���V�|�S)	$�)	$��*���I�I�f�l�b�l�l�B�G�G�&<�=�����%����� )�!� ��K�!��%�����M)	$�)	$�s��AI�)G5�=*I�1=I�/H0�2I� I�!A%I�!I�(I�5	H-�>*H(�(H-�-I�0	H=�9I�<H=�=I�	I
�	I�I
�
I�	I�I�I�I�I(c���tjj�dgttj�ztjddtj
j�y�Nr)rsr~r6rNr�rnrYrCr6�reset_cachezParserElement.reset_cachesO���#�#�)�)�+�01�s�S��-�-�6
�0
�
�)�)�!�,�	�%�%�+�+�-rCc��tj�dt_dt_tjt_y)a$
        Disables active Packrat or Left Recursion parsing and their memoization

        This method also works if neither Packrat nor Left Recursion are enabled.
        This makes it safe to call before activating Packrat nor Left Recursion
        to clear any previous settings.
        FN)rsr��_left_recursion_enabled�_packratEnabledrgr-rYrCr6�disable_memoizationz!ParserElement.disable_memoizations.��	�!�!�#�05�
�-�(-�
�%�,�:�:�
�rC)�forcec��|rtj�ntjrtd��|�t	�t_dt_y|dkDr!t
|��t_dt_ytd|����)a'
        Enables "bounded recursion" parsing, which allows for both direct and indirect
        left-recursion. During parsing, left-recursive :class:`Forward` elements are
        repeatedly matched with a fixed recursion depth that is gradually increased
        until finding the longest match.

        Example::

            import pyparsing as pp
            pp.ParserElement.enable_left_recursion()

            E = pp.Forward("E")
            num = pp.Word(pp.nums)
            # match `num`, or `num '+' num`, or `num '+' num '+' num`, ...
            E <<= E + '+' - num | num

            print(E.parse_string("1+2+3"))

        Recursion search naturally memoizes matches of ``Forward`` elements and may
        thus skip reevaluation of parse actions during backtracking. This may break
        programs with parse actions which rely on strict ordering of side-effects.

        Parameters:

        - ``cache_size_limit`` - (default=``None``) - memoize at most this many
          ``Forward`` elements during matching; if ``None`` (the default),
          memoize all ``Forward`` elements.

        Bounded Recursion parsing works similar but not identical to Packrat parsing,
        thus the two cannot be used together. Use ``force=True`` to disable any
        previous, conflicting settings.
        �0Packrat and Bounded Recursion are not compatibleNr)�capacityz
Memo size of T)	rsr�r��RuntimeError�_UnboundedMemorn�_LRUMemo�NotImplementedErrorr���cache_size_limitr�s  r6�enable_left_recursionz#ParserElement.enable_left_recursions|��H��-�-�/�
�
*�
*��Q�R�R��#�,:�,<�M�)�
15�
�-�	��
!�,4�>N�,O�M�)�15�
�-�&�
�6F�5G�&H�I�IrCc�&�|rtj�ntjrtd��tjrydt_|�t�t_nt|�t_tjt_	y)aj
        Enables "packrat" parsing, which adds memoizing to the parsing logic.
        Repeated parse attempts at the same string location (which happens
        often in many complex grammars) can immediately return a cached value,
        instead of re-executing parsing/validating code.  Memoizing is done of
        both valid results and parsing exceptions.

        Parameters:

        - ``cache_size_limit`` - (default= ``128``) - if an integer value is provided
          will limit the size of the packrat cache; if None is passed, then
          the cache size will be unbounded; if 0 is passed, the cache will
          be effectively disabled.

        This speedup may break existing programs that use parse actions that
        have side-effects.  For this reason, packrat parsing is disabled when
        you first import pyparsing.  To activate the packrat feature, your
        program must call the class method :class:`ParserElement.enable_packrat`.
        For best results, call ``enable_packrat()`` immediately after
        importing pyparsing.

        Example::

            import pyparsing
            pyparsing.ParserElement.enable_packrat()

        Packrat parsing works similar but not identical to Bounded Recursion parsing,
        thus the two cannot be used together. Use ``force=True`` to disable any
        previous, conflicting settings.
        r�NT)
rsr�r�r�r�rr~rr�r-r�s  r6�enable_packratzParserElement.enable_packratOsj��D��-�-�/�
�
2�
2��Q�R�R��(�(��(,�
�%��#�*9�*;�M�'�*4�5E�*F�M�'�,�8�8�
�rC)�parseAllc�B�|xs|}tj�|js|j�|jD]}|j��|j
s|j
�}	|j|d�\}}|rH|j||�}t�t�jd�z}|j||�|S#t$r}|j�d}~wt$r'}	tjr�|	j!d��d}	~	wwxYw)a8	
        Parse a string with respect to the parser definition. This function is intended as the primary interface to the
        client code.

        :param instring: The input string to be parsed.
        :param parse_all: If set, the entire input string must match the grammar.
        :param parseAll: retained for pre-PEP8 compatibility, will be removed in a future release.
        :raises ParseException: Raised if ``parse_all`` is set and the input string does not match the whole grammar.
        :returns: the parsed data as a :class:`ParseResults` object, which may be accessed as a `list`, a `dict`, or
          an object with attributes if the given parser includes results names.

        If the input string is required to match the entire grammar, ``parse_all`` flag must be set to ``True``. This
        is also equivalent to ending the grammar with :class:`StringEnd`\ ().

        To report proper column numbers, ``parse_string`` operates on a copy of the input string where all tabs are
        converted to spaces (8 spaces per tab, as per the default in ``string.expandtabs``). If the input string
        contains tabs and the grammar uses parse actions that use the ``loc`` argument to index into the string
        being parsed, one can ensure a consistent view of the input string by doing one of the following:

        - calling ``parse_with_tabs`` on your grammar before calling ``parse_string`` (see :class:`parse_with_tabs`),
        - define your parse action using the full ``(s,loc,toks)`` signature, and reference the input string using the
          parse action's ``s`` argument, or
        - explicitly expand the tabs in your input string before calling ``parse_string``.

        Examples:

        By default, partial matches are OK.

        >>> res = Word('a').parse_string('aaaaabaaa')
        >>> print(res)
        ['aaaaa']

        The parsing behavior varies by the inheriting class of this abstract class. Please refer to the children
        directly to see more examples.

        It raises an exception if parse_all flag is set and instring does not match the whole grammar.

        >>> res = Word('a').parse_string('aaaaabaaa', parse_all=True)
        Traceback (most recent call last):
        ...
        pyparsing.ParseException: Expected end of text, found 'b'  (at char 5), (line:1, col:6)
        rFN)rsr�r��
streamliner�r��
expandtabsr-rQ�Empty�	StringEnd�	set_debugrr�r�r�r�)
r�r��	parse_allr�rFr�rc�se�pa_excr�s
          r6�parse_stringzParserElement.parse_string�s���Z�(����!�!�#�����O�O���!�!�	�A�
�L�L�N�	��}�}��*�*�,�H�	��+�+�h��2�K�C����m�m�H�c�2���W�y�{�4�4�U�;�;���	�	�(�C�(��M��&�	��*�*���!�	+��/�/���$�$�T�*�*��	+�s%�5AC�	D�C+�+D�7"D�D)r��
maxMatchesc#�hK�t||�}|js|j�|jD]}|j��|jst|�j
�}t|�}d}	|r9t�}
|j|
_|j|
_	|
j}n|j}|j}tj�d}
	|	|kr}|
|krw	|||	�}|||d��\}}||	kDrG|
dz
}
|rt|j�||d��|||f��|r|||	�}||	kDr|}	n|	dz
}	n	|}	n|dz}		|	|kr|
|kr�uyyyy#t $rdz}	Y�wxYw#t"$r'}tj$r�|j'd��d}~wwxYw�w)at
        Scan the input string for expression matches.  Each match will return the
        matching tokens, start location, and end location.  May be called with optional
        ``max_matches`` argument, to clip scanning after 'n' matches are found.  If
        ``overlap`` is specified, then overlapping matches will be reported.

        Note that the start and end locations are reported relative to the string
        being parsed.  See :class:`parse_string` for more information on parsing
        strings with embedded tabs.

        Example::

            source = "sldjf123lsdjjkf345sldkjf879lkjsfd987"
            print(source)
            for tokens, start, end in Word(alphas).scan_string(source):
                print(' '*start + '^'*(end-start))
                print(' '*start + tokens[0])

        prints::

            sldjf123lsdjjkf345sldkjf879lkjsfd987
            ^^^^^
            sldjf
                    ^^^^^^^
                    lsdjjkf
                              ^^^^^^
                              sldkjf
                                       ^^^^^^
                                       lkjsfd
        rF�r(r)rc�start�endN)�minr�r�r�r�rtr�rNr�r�rQr-rs�
resetCacher�r[r�r�r�r�)r�r��max_matches�overlap�always_skip_whitespacer�r�rFrOr��	preparser�
preparseFn�parseFn�matches�preloc�nextLocrc�nextlocr�s                   r6�scan_stringzParserElement.scan_string�s�����P��[�1�
�����O�O���!�!�	�A�
�L�L�N�	��}�}��8�}�/�/�1�H��x�=����!���I�$(�$4�$4�I�!�#'�?�?�I� �"�+�+�J����J��+�+��� � �"���$	+���/�g�
�&:�)�",�X�s�";�F�'.�h��U�&S�O�G�V���}��1��� �!�.4�m�m�o�-3�+2�!"��%�f�g�5�5�"�&0��3�&?�G�&��}�&-�� #�q���")�C�$�q�j��;��/�g�
�&:�/�&:�/��&�%� �1�*�C�%��0"�	+��/�/���$�$�T�*�*��	+�sO�C%F2�(
E?�3E+�
AE?�'F2�+E<�9E?�;E<�<E?�?	F/�"F*�*F/�/F2�r�c��g}d}d|_	|j||��D]�\}}}||kDr|j|||�|}|s�%t|t�r||j�z
}�It|t�r"t|t�s|j|��{|j|���|j||d�|D�cgc]}|s�|��	}}djt|�D�cgc]
}t|���c}�Scc}wcc}w#t$r'}	tjr�|	jd��d}	~	wwxYw)ab
        Extension to :class:`scan_string`, to modify matching text with modified tokens that may
        be returned from a parse action.  To use ``transform_string``, define a grammar and
        attach a parse action to it that modifies the returned token list.
        Invoking ``transform_string()`` on a target string will then scan for matches,
        and replace the matched text patterns according to the logic in the parse
        action.  ``transform_string()`` returns the resulting transformed string.

        Example::

            wd = Word(alphas)
            wd.set_parse_action(lambda toks: toks[0].title())

            print(wd.transform_string("now is the winter of our discontent made glorious summer by this sun of york."))

        prints::

            Now Is The Winter Of Our Discontent Made Glorious Summer By This Sun Of York.
        rTr�Nrf)r�r�r
r^r r�rr#r�joinrrtr�rsr�r�)
r�r�r��out�lastEr�r�rF�or�s
          r6�transform_stringzParserElement.transform_string)s,��(������
�	+��+�+�H�E�+�B�

"���1�a��u�9��J�J�x��a�0�1������a��.��1�9�9�;�&�C���8�,�Z��8�5L��J�J�q�M��J�J�q�M�

"�
�J�J�x���'�(�!�'��Q�1�'�C�'��7�7�H�S�M�:�q�C��F�:�;�;��(��:��!�	+��/�/���$�$�T�*�*��	+�s<�B9D�D�D�D�,D
�>D�
D�	D?�"D:�:D?c
��t||�}	t|j||d|��D���cgc]\}}}|��
c}}}�Scc}}}w#t$r'}tj
r�|j
d��d}~wwxYw)a�
        Another extension to :class:`scan_string`, simplifying the access to the tokens found
        to match the given parse expression.  May be called with optional
        ``max_matches`` argument, to clip searching after 'n' matches are found.

        Example::

            # a capitalized word starts with an uppercase letter, followed by zero or more lowercase letters
            cap_word = Word(alphas.upper(), alphas.lower())

            print(cap_word.search_string("More than Iron, more than Lead, more than Gold I need Electricity"))

            # the sum() builtin can be used to merge results into a single ParseResults object
            print(sum(cap_word.search_string("More than Iron, more than Lead, more than Gold I need Electricity")))

        prints::

            [['More'], ['Iron'], ['Lead'], ['Gold'], ['I'], ['Electricity']]
            ['More', 'Iron', 'Lead', 'Gold', 'I', 'Electricity']
        F)r�r�N)r�r r�r�rsr�r�)	r�r�r�r�r�r�r�rFr�s	         r6�
search_stringzParserElement.search_string\s���8��[�1�
�	+��$(�#3�#3� �*�U�RW�$4�$�����1�a����
����"�	+��/�/���$�$�T�*�*��	+�s'�A	�
A�A	�A	�		A9�"A4�4A9)�includeSeparatorsc#�K�|xs|}d}|j||��D]\}}}|||��|r|d��|}�||d��y�w)aT
        Generator method to split a string using the given expression as a separator.
        May be called with optional ``maxsplit`` argument, to limit the number of splits;
        and the optional ``include_separators`` argument (default= ``False``), if the separating
        matching text should be included in the split results.

        Example::

            punc = one_of(list(".,;:/-!?"))
            print(list(punc.split("This, this?, this sentence, is badly punctuated!")))

        prints::

            ['This', ' this', '', ' this sentence', ' is badly punctuated', '']
        r)r�N)r�)	r�r��maxsplit�include_separatorsr��lastr�r�rFs	         r6r2zParserElement.split�sj����..�C�1C�����'�'��h�'�G�	�G�A�q�!��4��"�"� ���d�
��D�		�
�t�u�o��s�?Ac��|turt|�St|t�r|j	|�}t|t
�stSt||g�S)al
        Implementation of ``+`` operator - returns :class:`And`. Adding strings to a :class:`ParserElement`
        converts them to :class:`Literal`\ s by default.

        Example::

            greet = Word(alphas) + "," + Word(alphas) + "!"
            hello = "Hello, World!"
            print(hello, "->", greet.parse_string(hello))

        prints::

            Hello, World! -> ['Hello', ',', 'World', '!']

        ``...`` may be used as a parse expression as a short form of :class:`SkipTo`::

            Literal('start') + ... + Literal('end')

        is equivalent to::

            Literal('start') + SkipTo('end')("_skipped*") + Literal('end')

        Note that the skipped text is returned with '_skipped' as a results name,
        and to support having multiple skips in the same parser, the value returned is
        a list of all skipped text.
        )�Ellipsis�_PendingSkipr^r#r�rs�NotImplemented�And�r��others  r6�__add__zParserElement.__add__�sP��6�H����%�%��e�X�&��,�,�U�3�E��%��/�!�!��D�%�=�!�!rCc��|turt|�d�|zSt|t�r|j	|�}t|t
�stS||zS)zd
        Implementation of ``+`` operator when left operand is not a :class:`ParserElement`
        �	_skipped*)r��SkipTor^r#r�rsr�r�s  r6�__radd__zParserElement.__radd__�sV���H���6�$�<��,�t�3�3��e�X�&��,�,�U�3�E��%��/�!�!��t�|�rCc��t|t�r|j|�}t|t�stS|t
j
�z|zS)zX
        Implementation of ``-`` operator, returns :class:`And` with error stop
        )r^r#r�rsr�r��
_ErrorStopr�s  r6�__sub__zParserElement.__sub__�sE���e�X�&��,�,�U�3�E��%��/�!�!��c�n�n�&�&��.�.rCc�z�t|t�r|j|�}t|t�stS||z
S)zd
        Implementation of ``-`` operator when left operand is not a :class:`ParserElement`
        �r^r#r�rsr�r�s  r6�__rsub__zParserElement.__rsub__��8���e�X�&��,�,�U�3�E��%��/�!�!��t�|�rCc�T���|turd}n+t|t�r|ddtfk(rd|ddzdzdd}t|ttf�stSt|t�r|d}}n�td�|D��}|d	zdd}|d�d|df}t|dt�r?|d�:|ddk(rt��S|ddk(rt
��S�|dzt��zSt|dt�rt|dt�r|\}}||z}ntS|dkrtd
��|dkrtd��||cxk(rdk(rtg�S|r>��fd��|r,|dk(r
��|�z}|St�g|z��|�z}|S�|�}|S|dk(r�}|St�g|z�}|S)
a�
        Implementation of ``*`` operator, allows use of ``expr * 3`` in place of
        ``expr + expr + expr``.  Expressions may also be multiplied by a 2-integer
        tuple, similar to ``{min, max}`` multipliers in regular expressions.  Tuples
        may also include ``None`` as in:

        - ``expr*(n, None)`` or ``expr*(n, )`` is equivalent
          to ``expr*n + ZeroOrMore(expr)``
          (read as "at least n instances of ``expr``")
        - ``expr*(None, n)`` is equivalent to ``expr*(0, n)``
          (read as "0 to n instances of ``expr``")
        - ``expr*(None, None)`` is equivalent to ``ZeroOrMore(expr)``
        - ``expr*(1, None)`` is equivalent to ``OneOrMore(expr)``

        Note that ``expr*(None, n)`` does not raise an exception if
        more than n exprs exist in the input stream; that is,
        ``expr*(None, n)`` does not enforce a maximum number of expr
        occurrences.  If this behavior is desired, then write
        ``expr*(None, n) + ~expr``
        )rNNr�rr=rSrc3�4K�|]}|tur|nd���y�wr=)r�)r4r�s  r6r�z(ParserElement.__mul__.<locals>.<genexpr>s����J�q�q��0�!�d�:�J���)NNz/cannot multiply ParserElement by negative valuez@second tuple value must be greater or equal to first tuple valuec�R��|dkDrt��|dz
�z�St��SrM)�Opt)�n�makeOptionalListr�s ��r6r�z/ParserElement.__mul__.<locals>.makeOptionalList*s.����q�5��t�&6�q�1�u�&=�=�>�>��t�9�$rC)	r�r^r�r�r��
ZeroOrMore�	OneOrMore�
ValueErrorr�)r�r��minElements�optElementsr�r�s`    @r6�__mul__zParserElement.__mul__�s���*�H���E�
��u�
%�%���)��{�*B��E�!�"�I�%��/��!�4�E��%�#�u��.�!�!��e�S�!�',�a��K��J�E�J�J�E��\�)�2�A�.�E��Q�x���E�!�H�
���%��(�C�(�U�1�X�-=���8�q�=�%�d�+�+���8�q�=�$�T�?�*��%��(�?�Z��-=�=�=��E�!�H�c�*�z�%��(�C�/H�+0�(��[��{�*��%�%���?��N�O�O���?��R��
��+�*��*��r�7�N�+��
%���!�#��!1�+�!>�>�C��
��t�f�{�2�3�6F�{�6S�S�C��
�
'�{�3���
�	�a�����
��4�&�;�.�/���
rCc�$�|j|�Sr=)r�r�s  r6�__rmul__zParserElement.__rmul__>s���|�|�E�"�"rCc���|tur
t|d��St|t�r!|dk(rt	|�S|j|�}t|t�stSt||g�S)zP
        Implementation of ``|`` operator - returns :class:`MatchFirst`
        T)�	must_skiprf)	r�r�r^r#r�r�rsr��
MatchFirstr�s  r6�__or__zParserElement.__or__Asc���H�����5�5��e�X�&���{��4�y� ��,�,�U�3�E��%��/�!�!��4��-�(�(rCc�z�t|t�r|j|�}t|t�stS||zS)zd
        Implementation of ``|`` operator when left operand is not a :class:`ParserElement`
        r�r�s  r6�__ror__zParserElement.__ror__Qr�rCc��t|t�r|j|�}t|t�stSt||g�S)zH
        Implementation of ``^`` operator - returns :class:`Or`
        )r^r#r�rsr��Orr�s  r6�__xor__zParserElement.__xor__[s=���e�X�&��,�,�U�3�E��%��/�!�!��4��-� � rCc�z�t|t�r|j|�}t|t�stS||zS)zd
        Implementation of ``^`` operator when left operand is not a :class:`ParserElement`
        r�r�s  r6�__rxor__zParserElement.__rxor__er�rCc��t|t�r|j|�}t|t�stSt||g�S)zJ
        Implementation of ``&`` operator - returns :class:`Each`
        )r^r#r�rsr��Eachr�s  r6�__and__zParserElement.__and__os=���e�X�&��,�,�U�3�E��%��/�!�!��T�5�M�"�"rCc�z�t|t�r|j|�}t|t�stS||zS)zd
        Implementation of ``&`` operator when left operand is not a :class:`ParserElement`
        r�r�s  r6�__rand__zParserElement.__rand__yr�rCc��t|�S)zL
        Implementation of ``~`` operator - returns :class:`NotAny`
        )�NotAnyrs r6�
__invert__zParserElement.__invert__�s���d�|�rCc�j�d}t�}t|t�r|j|j}}|�d}d}nHt|t
�r8t|dt�r%|d|djf|dj}}d}t|t�r|f}	t|�t|�dkDr1td	|dd
�t|�d
kDrdt|��d�nd
�d���|t|dd�z}tjt|�}|r|j|�|S#t$r||f}Y��wxYw)a�
        use ``[]`` indexing notation as a short form for expression repetition:

        - ``expr[n]`` is equivalent to ``expr*n``
        - ``expr[m, n]`` is equivalent to ``expr*(m, n)``
        - ``expr[n, ...]`` or ``expr[n,]`` is equivalent
             to ``expr*n + ZeroOrMore(expr)``
             (read as "at least n instances of ``expr``")
        - ``expr[..., n]`` is equivalent to ``expr*(0, n)``
             (read as "0 to n instances of ``expr``")
        - ``expr[...]`` and ``expr[0, ...]`` are equivalent to ``ZeroOrMore(expr)``
        - ``expr[1, ...]`` is equivalent to ``OneOrMore(expr)``

        ``None`` may be used in place of ``...``.

        Note that ``expr[..., n]`` and ``expr[m, n]`` do not raise an exception
        if more than ``n`` ``expr``\ s exist in the input stream.  If this behavior is
        desired, then write ``expr[..., n] + ~expr``.

        For repetition with a stop_on expression, use slice notation:

        - ``expr[...: end_expr]`` and ``expr[0, ...: end_expr]`` are equivalent to ``ZeroOrMore(expr, stop_on=end_expr)``
        - ``expr[1, ...: end_expr]`` is equivalent to ``OneOrMore(expr, stop_on=end_expr)``

        FN.Tr�rrrSz'only 1 or 2 index arguments supported (rVz... [�]rf�))�NoMatchr^�slicer��stopr�r#�iterr�rN�typingr�_MultipleMatch�stopOn)r��key�stop_on_defined�stop_onr�s     r6�__getitem__zParserElement.__getitem__�s=��6 ���)���c�5�!��9�9�c�h�h��C��{���"�O�
��U�
#�
�3�r�7�E�(B���F�C��F�L�L�1�3�q�6�;�;��C�"�O��c�8�$��&�C�	���I��s�8�a�<��9�#�b�q�'��Z]�^a�Zb�ef�Zf�U�3�s�8�*�TU�CV�ln�Bo�op�q��
�
�U�3�r��7�^�#���k�k�.�#�.����J�J�w���
���	���*�C�	�s�D"�"
D2�1D2c�H�|�|j|�S|j�S)a
        Shortcut for :class:`set_results_name`, with ``list_all_matches=False``.

        If ``name`` is given with a trailing ``'*'`` character, then ``list_all_matches`` will be
        passed as ``True``.

        If ``name`` is omitted, same as calling :class:`copy`.

        Example::

            # these are equivalent
            userdata = Word(alphas).set_results_name("name") + Word(nums + "-").set_results_name("socsecno")
            userdata = Word(alphas)("name") + Word(nums + "-")("socsecno")
        )rr�r�rAs  r6�__call__zParserElement.__call__�s'�����'�'��-�-��y�y�{�rCc��t|�S)z�
        Suppresses the output of this :class:`ParserElement`; useful to keep punctuation from
        cluttering up returned output.
        )�Suppressrs r6�suppresszParserElement.suppress�s��
��~�rCc��d|_|S)z�
        Enables the skipping of whitespace before matching the characters in the
        :class:`ParserElement`'s defined pattern.

        :param recursive: If ``True`` (the default), also enable whitespace skipping in child elements (if any)
        T�r��r��	recursives  r6�ignore_whitespacezParserElement.ignore_whitespace�s��#����rCc��d|_|S)a|
        Disables the skipping of whitespace before matching the characters in the
        :class:`ParserElement`'s defined pattern.  This is normally only used internally by
        the pyparsing module, but may be needed in some whitespace-sensitive grammars.

        :param recursive: If true (the default), also disable whitespace skipping in child elements (if any)
        Frrs  r6�leave_whitespacezParserElement.leave_whitespace�s��$����rCc�B�d|_t|�|_||_|S)z8
        Overrides the default whitespace chars
        T)r�r�r�r�)r�r��
copy_defaultss   r6�set_whitespace_charsz"ParserElement.set_whitespace_chars�s$��#����e�*���%2��"��rCc��d|_|S)z�
        Overrides default behavior to expand ``<TAB>`` s to spaces before parsing the input string.
        Must be called before ``parse_string`` when the input grammar contains elements that
        match ``<TAB>`` characters.
        T)r�rs r6�parse_with_tabszParserElement.parse_with_tabss����
��rCc��t|t�rt|�}t|t�r+||jvr|jj	|�|S|jj	t|j���|S)a�
        Define expression to be ignored (e.g., comments) while doing pattern
        matching; may be called repeatedly, to define multiple comment or other
        ignorable patterns.

        Example::

            patt = Word(alphas)[...]
            patt.parse_string('ablaj /* comment */ lskjd')
            # -> ['ablaj']

            patt.ignore(c_style_comment)
            patt.parse_string('ablaj /* comment */ lskjd')
            # -> ['ablaj', 'lskjd']
        )r^r#rr�r
rr�s  r6�ignorezParserElement.ignore
sp�� �e�X�&��U�O�E��e�X�&��D�,�,�,�� � �'�'��.���
���#�#�H�U�Z�Z�\�$:�;��rCc�t�|j|xst|xst|xst�|_d|_|S)a 
        Customize display of debugging messages while doing pattern matching:

        - ``start_action`` - method to be called when an expression is about to be parsed;
          should have the signature ``fn(input_string: str, location: int, expression: ParserElement, cache_hit: bool)``

        - ``success_action`` - method to be called when an expression has successfully parsed;
          should have the signature ``fn(input_string: str, start_location: int, end_location: int, expression: ParserELement, parsed_tokens: ParseResults, cache_hit: bool)``

        - ``exception_action`` - method to be called when expression fails to parse;
          should have the signature ``fn(input_string: str, location: int, expression: ParserElement, exception: Exception, cache_hit: bool)``
        T)r�r�r�r�r�r�)r��start_action�success_action�exception_actions    r6�set_debug_actionszParserElement.set_debug_actions's@��$!�-�-��7�7��;�;��?� ?�
���
��
��rCc��|r*|j�D]}|j|d���|S|r!|jttt
�|Sd|_|S)a
        Enable display of debugging messages while doing pattern matching.
        Set ``flag`` to ``True`` to enable, ``False`` to disable.
        Set ``recurse`` to ``True`` to set the debug flag on this expression and all sub-expressions.

        Example::

            wd = Word(alphas).set_name("alphaword")
            integer = Word(nums).set_name("numword")
            term = wd | integer

            # turn on debugging for wd
            wd.set_debug()

            term[1, ...].parse_string("abc 123 xyz 890")

        prints::

            Match alphaword at loc 0(1,1)
            Matched alphaword -> ['abc']
            Match alphaword at loc 3(1,4)
            Exception raised:Expected alphaword (at char 4), (line:1, col:5)
            Match alphaword at loc 7(1,8)
            Matched alphaword -> ['xyz']
            Match alphaword at loc 11(1,12)
            Exception raised:Expected alphaword (at char 12), (line:1, col:13)
            Match alphaword at loc 15(1,16)
            Exception raised:Expected alphaword (at char 15), (line:1, col:16)

        The output shown is that produced by the default debug actions - custom debug actions can be
        specified using :class:`set_debug_actions`. Prior to attempting
        to match the ``wd`` expression, the debugging message ``"Match <exprname> at loc <n>(<line>,<col>)"``
        is shown. Then if the parse succeeds, a ``"Matched"`` message is shown, or an ``"Exception raised"``
        message is shown. Also note the use of :class:`set_name` to assign a human-readable name to the expression,
        which makes debugging and exception messages easier to understand - for instance, the default
        name created for the :class:`Word` expression without calling ``set_name`` is ``"W:(A-Za-z)"``.
        F)r)rr�r(r�r�r�r�)r��flagrr�s    r6r�zParserElement.set_debugAsb��L����(�
4�����t�U��3�
4��K���"�"�+�-�/�
����D�J��rCc�\�|j�|j�|_|jSr=)r��_generateDefaultNamers r6�default_namezParserElement.default_namevs+�����$� $� 9� 9� ;�D��� � � rCc��y)zg
        Child classes must define this method, which defines how the ``default_name`` is set.
        NrYrs r6r,z"ParserElement._generateDefaultName|r�rCc��||_dt|���|_tjr|j|du�|S)a�
        Define name for this expression, makes debugging and exception messages clearer. If
        `__diag__.enable_debug_on_named_expressions` is set to True, setting a name will also
        enable debug for this expression.

        If `name` is None, clears any custom name for this expression, and clears the
        debug flag is it was enabled via `__diag__.enable_debug_on_named_expressions`.

        Example::

            integer = Word(nums)
            integer.parse_string("ABC")  # -> Exception: Expected W:(0-9) (at char 0), (line:1, col:1)

            integer.set_name("integer")
            integer.parse_string("ABC")  # -> Exception: Expected integer (at char 0), (line:1, col:1)
        �	Expected N)r�rtr�r8rNr�rs  r6�set_namezParserElement.set_name�s<��"���!�#�d�)��-����5�5��N�N�4�t�+�,��rCc�J�|j�|jS|jSr=)r�r-rs r6rAzParserElement.name�s"��#'�/�/�"=�t���T�4�CT�CT�TrCc�&�|j|�yr=)r1)r��new_names  r6rAzParserElement.name�s���
�
�h�rCc��|jSr=�rArs r6�__str__zParserElement.__str__�s���y�y�rCc��t|�Sr=�rtrs r6�__repr__zParserElement.__repr__�s���4�y�rCc�"�d|_d|_|S�NT)r�r�rs r6r�zParserElement.streamline�s����� ����rCc��gSr=rYrs r6rzParserElement.recurse�����	rCc�b�|dd|gz}|j�D]}|j|��yr=)r�_checkRecursion�r��parseElementList�subRecCheckListrFs    r6r@zParserElement._checkRecursion�s6��*�1�-���6������	/�A�
���o�.�	/rCc�^�tjdtd��|jg�y)zj
        Check defined expressions for valid structure, check for infinite recursive definitions.
        �ZParserElement.validate() is deprecated, and should not be used to check for left recursionrS��
stacklevelN)�warningsr:�DeprecationWarningr@)r��
validateTraces  r6�validatezParserElement.validate�s)��	�
�
�h���	
�
	
���R� rCc��|xs|}	tjt|�}|j�}	|j|�S#t$rQtjt
|�}t
|d|��5}|j�}ddd�n#1swYnxYwY�lwxYw#t$r'}tjr�|jd��d}~wwxYw)z�
        Execute the parse expression on the given file or filename.
        If a filename is specified (instead of a file object),
        the entire file is opened, read, and closed before parsing.
        �r��encodingN)r	rr
�read�AttributeErrorrt�openr�r�rsr�r�)r��file_or_filenamerOr�r��
file_contents�fr�s        r6�
parse_filezParserElement.parse_file�s����(�y��	)�%�{�{�6�3C�D��,�1�1�3�M�
	+��$�$�]�H�=�=���	)�%�{�{�3�0@�A���&��h�?�
)�1� !����
�
)�
)�
)��	)��"�	+��/�/���$�$�T�*�*��	+�s@�*A�B"�1B�6B�	B�B	�B�B�"	C�+"C
�
Cc��||uryt|t�r|j|d��St|t�rt	|�t	|�k(Sy)NT�r�F)r^r#r�rs�varsr�s  r6�__eq__zParserElement.__eq__�sI���5�=��
��x�
(��<�<���<�6�6�
��}�
-���:��e��,�,�rCc��t|�Sr=)�idrs r6�__hash__zParserElement.__hash__�s���$�x�rCc�h�|xr|}	|jt|�|��y#t$rYywxYw)a�
        Method for quick testing of a parser against a test string. Good for simple
        inline microtests of sub expressions while building up larger parser.

        Parameters:

        - ``test_string`` - to test against this expression for a match
        - ``parse_all`` - (default= ``True``) - flag to pass to :class:`parse_string` when running tests

        Example::

            expr = Word(nums)
            assert expr.matches("100")
        rXTF)r�rtr�)r��test_stringr�r�s    r6r�zParserElement.matches�s@��"�)�	��	����c�+�.�(��C���!�	��	�s�%�	1�1)r��fullDump�printResults�failureTestsrYc
	�
�ddlm}|
xr|}
|xr|}|xr|}|
xs|}
|xs|}t|t�r`t	j
t|�}t|�j}|j�j�D�cgc]
}||���}}|du}|r5t|t�r%t	j
t|�}t|�}t	j
t|�}|�tj}|j}g}g}d}td�j!t#d��j%t&�}d}d}|D�]�}|r|j)|d�s|r'|s%|j+|	r|j-|�n|��A|s�D|�|r|j/|�nd	��|	r|j-|�n|g}|j1�	|j3|j5|��}|j7||
�
�}|xr|
}|�w	|||�}|�Kt|t8�r |j+|j;��n:|j+t
|��n|j+|j;��n"|j+|j;|���	|j+d	�|r|dj/|��|j+||f����||fScc}w#t<$ra}|j+|j;|���|j+|j>�dt|�j>�d
|���Yd}~��d}~wwxYw#t@$r�}t|tB�rdnd	} |j+|jE��|j+d| �|���tjFr.|jItKjL|jN��|xr|
}|}Yd}~��Td}~wt<$r�}!d}"|!jN}#tQtKjR|#��}$|$D]Q\}%}&|%jTjV|&ftXk(s�&t[|$�d}'|"d|'jTj\�d�z
}"n|j+|"�d
t|!�j>�d
|!���tjFr.|jItKjL|!jN��|xr|
}|!}Yd}!~!��Zd}!~!wwxYw)a�

        Execute the parse expression on a series of test strings, showing each
        test, the parsed results or where the parse failed. Quick and easy way to
        run a parse expression against a list of sample strings.

        Parameters:

        - ``tests`` - a list of separate test strings, or a multiline string of test strings
        - ``parse_all`` - (default= ``True``) - flag to pass to :class:`parse_string` when running tests
        - ``comment`` - (default= ``'#'``) - expression for indicating embedded comments in the test
          string; pass None to disable comment filtering
        - ``full_dump`` - (default= ``True``) - dump results as list followed by results names in nested outline;
          if False, only dump nested list
        - ``print_results`` - (default= ``True``) prints test output to stdout
        - ``failure_tests`` - (default= ``False``) indicates if these tests are expected to fail parsing
        - ``post_parse`` - (default= ``None``) optional callback for successful parse results; called as
          `fn(test_string, parse_results)` and returns a string to be added to the test output
        - ``file`` - (default= ``None``) optional file-like object to which test output will be written;
          if None, will default to ``sys.stdout``
        - ``with_line_numbers`` - default= ``False``) show test strings with line and column numbers

        Returns: a (success, results) tuple, where success indicates that all tests succeeded
        (or failed if ``failure_tests`` is True), and the results contain a list of lines of each
        test's output

        Example::

            number_expr = pyparsing_common.number.copy()

            result = number_expr.run_tests('''
                # unsigned integer
                100
                # negative integer
                -100
                # float with scientific notation
                6.02e23
                # integer with scientific notation
                1e-12
                ''')
            print("Success" if result[0] else "Failed!")

            result = number_expr.run_tests('''
                # stray character
                100Z
                # missing leading digit before '.'
                -.100
                # too many '.'
                3.14.159
                ''', failure_tests=True)
            print("Success" if result[0] else "Failed!")

        prints::

            # unsigned integer
            100
            [100]

            # negative integer
            -100
            [-100]

            # float with scientific notation
            6.02e23
            [6.02e+23]

            # integer with scientific notation
            1e-12
            [1e-12]

            Success

            # stray character
            100Z
               ^
            FAIL: Expected end of text (at char 3), (line:1, col:4)

            # missing leading digit before '.'
            -.100
            ^
            FAIL: Expected {real number with scientific notation | real number | signed integer} (at char 0), (line:1, col:1)

            # too many '.'
            3.14.159
                ^
            FAIL: Expected end of text (at char 4), (line:1, col:5)

            Success

        Each test string must be on a single line. If you want to test a string that spans multiple
        lines, create a test like this::

            expr.run_tests(r"this is a test\n of strings that spans \n 3 lines")

        (Note that this is a raw string literal, you must include the leading ``'r'``.)
        r)�pyparsing_testNT�\n�
uFrfrX)�fullz	 failed: �: z(FATAL) zFAIL: zFAIL-EXCEPTIONrz (raised in parse action r)/�testingrdr^r#r	rrtr��strip�rstrip�
splitlines�Literalrs�sys�stdout�writer>�replace_withr#�
quoted_stringr�r
�with_line_numbersr�r6r��lstripr�r �dumpr]r)r�r��explainr�rr��	format_tbr�r�walk_tb�f_code�co_filenamer��next�co_name)(r��testsr��comment�	full_dump�
print_results�
failure_tests�
post_parse�filersr�r`rarbrYrd�
line_strip�	test_line�comment_specified�print_�
allResults�comments�success�NL�BOM�nlstrr�r�r��pp_valuerFr�r�r��tagr��itrUr��next_fs(                                        r6�	run_testszParserElement.run_testss|��j	,��)�	���)�	��#�5�
��#�4�}���+��	��e�X�&��K�K��U�+�E��e��*�*�J�<A�L�L�N�<U�<U�<W�X�y�Z�	�*�X�E�X�#�4�/����'�8�,� �+�+�c�7�3��!�'�*���+�+�m�W�5���<��:�:�D�����HJ�
� ����
�U�^�
,�
,�\�$�-?�
@�
G�
G�
�
V�������B	+�A� �W�_�_�Q��%>�(�ST����;L�N�4�4�Q�7�RS������'�(�%�*�*�X�.��C�D�7H��0�0��3�a��C�
�N�N��/
;��'�'�����
�6���*�*�1��*�A��6"�6�,�&6���(�
�#,�Q��#7��#�/�)�(�L�A� #�
�
�8�=�=�?� ;� #�
�
�3�x�=� 9��J�J�v�{�{�}�5���J�J�v�{�{��{�9�:��J�J�r�N���t�y�y��~�&����q�&�k�*�EB	+�H�
�"�"��mY��P%���
�
�6�;�;�H�;�#=�>��
�
�(�1�1�2�)�D��G�<L�<L�;M�R�PQ�s�S������K&�
�&0��5H�&I�
�r���
�
�2�:�:�<�(��
�
�V�E�7�2�$�/�0� �3�3��J�J�y�2�2�2�3C�3C�D�E�!�2�l������
�&���&�&���)�+�+�B�/�0��!��G�A�t����,�,�d�3�7I�I�!%�b��!����!:�6�=�=�;P�;P�:S�ST�U�U���	��
�
�c�U�"�T�#�Y�%7�%7�$8��3�%�@�A� �3�3��J�J�y�2�2�3�3D�3D�E�F�!�2�l�����!
�sM�K&�
3M�
A5K+�+	M�4AM�M�	T�!BO6�6T�AS<�B S<�<Tc�h�	ddlm}m}	|j�|||||||��}t
|ttf�s|j|	|fd|i|���yt|dd�	�5}|j|	|fd|i|���ddd�y#t$r}
t	d�|
�d}
~
wwxYw#1swYyxYw)
a�
        Create a railroad diagram for the parser.

        Parameters:

        - ``output_html`` (str or file-like object) - output target for generated
          diagram HTML
        - ``vertical`` (int) - threshold for formatting multiple alternatives vertically
          instead of horizontally (default=3)
        - ``show_results_names`` - bool flag whether diagram should show annotations for
          defined results names
        - ``show_groups`` - bool flag whether groups should be highlighted with an unlabeled surrounding box
        - ``show_hidden`` - bool flag to show diagram elements for internal elements that are usually hidden
        - ``embed`` - bool flag whether generated HTML should omit <HEAD>, <BODY>, and <DOCTYPE> tags to embed
          the resulting HTML in an enclosing HTML source
        - ``head`` - str containing additional HTML to insert into the <HEAD> section of the generated code;
          can be used to insert custom CSS styling
        - ``body`` - str containing additional HTML to insert at the beginning of the <BODY> section of the
          generated code

        Additional diagram-formatting keyword arguments can also be included;
        see railroad.Diagram class.
        r)�to_railroad�railroad_to_htmlzMmust ``pip install pyparsing[diagrams]`` to generate parser railroad diagramsN)�vertical�show_results_names�show_groups�show_hidden�diagram_kwargs�embed�w�utf-8rN)�diagramr�r��ImportErrorr]r�r^rtrrprR)
r��output_htmlr�r�r�r�r�r;r�r�r��railroad�	diag_files
             r6�create_diagramzParserElement.create_diagram�s���D	�>�	
�������1�#�#�!�

���+��T�{�3����.�x�O�u�O��O�P��
�+�s�W�
5�	O���O�O�,�X�M�U�M�f�M�N�	O�	O��)�	��_���
��	��(	O�	O�s#�B�'B(�	B%�B � B%�(B1�inlineLiteralsUsing�setDefaultWhitespaceChars�disableMemoization�enableLeftRecursion�
enablePackratr��setResultsName�setBreak�setParseAction�addParseAction�addCondition�
setFailAction�tryParse�parseString�
scanString�transformString�searchString�ignoreWhitespace�leaveWhitespace�setWhitespaceChars�
parseWithTabs�setDebugActions�setDebug�setName�	parseFile�runTests�canParseNext)r�rtrErF)r@r�rErF�F)rrgrErF)rrRrErs�rErs)rArtrrgrrgrErs�T)r/rgrErs)r:�ParseActionr;rrErs)r:�ParseConditionr;rrErs)r��ParseFailActionrErs�r�rtr�r�rEr��rE�ParseImplReturnTyper,)rEztuple[int, ParseResults])
r�rtr�r�rhrgr'rgrEr�)r�rtr�r�r'rgrErgrDr=)r��typing.Optional[int]rErF)�)r�zUnion[int, None]r�rgrErF)r�rtr�rgr�rgrEr )r�rtr�r�r�rgr�rgr�r�rEz4Generator[tuple[ParseResults, int, int], None, None])r�rtr�rgrErt)
r�rtr�r�r�rgr�r�rEr )r�rtr�r�r�rgrEzGenerator[str, None, None])rA�typing.Optional[str]rErs�rrgrErs)r�zUnion[set[str], str]rrgrErs)r�rsrErs)r%�DebugStartActionr&�DebugSuccessActionr'�DebugExceptionActionrErs)TF)r*rgrrgrErs�rErt�rE�list[ParserElement])r�F)
rSzUnion[str, Path, TextIO]rOrtr�rgr�rgrEr )r_rtr�rgr�rgrErg)T�#TTFNNF)r}zUnion[str, list[str]]r�rgr~�*typing.Optional[Union[ParserElement, str]]rrgr�rgr�rgr��Dtyping.Optional[Callable[[str, ParseResults], typing.Optional[str]]]r�ztyping.Optional[TextIO]rsrgr�rgr`rgrargrbrgrYr�rEz=tuple[bool, list[tuple[str, Union[ParseResults, Exception]]]])rTFFFF)r�zUnion[TextIO, Path, str]r�r�r�rgr�rgr�rgr�rgrErF)�r)r*r+r,r�r�r�r��staticmethodr�r�rPr�rr�r��propertyr�setterrrrr rr0r<r>r@rBrKrQrTrYrgrkrmr�recursion_lockrnr	�Protocolrw�dictr}r~r�r�r�r-r�r�r�r�r�r�r��_MAX_INTr�r�r�r2r�r�r�r�r�r�r�r�r�r�r�r�r�__iter__rrrrrrr!r#r(r�r-rr,r1rAr7r:r�rr@rKrVrZr]r�r�r�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��defaultNamerYrCr6rsrs�sC��3�(���(�$���$� $���$��-��-�(�0��0�*�	=��	=�:�z�:�
$�:�&��&����'��'�� �"�<38� :�SX� :�� :�+/� :�LP� :�	� :�D	��(V�p
�#�J� �*
���
<@�c�	!�c�T"� �

C��
C��
C�
�
C��

C�

�
C���W�N�	����%�V�_�_�%�
%�D�
%�"!*��M�:�+�����a�&��
<@�.$�	!�.$�`�F��.��.��O�#���;��;��15�-5�@E�-5�.�-5�	
�-5��-5�^�-0�.9�CH�.9�*�.9�<@�.9�	
�.9��.9�b05�E�JO�E��E�(,�E�CG�E�	�E�T$��#�`+��"�`+��`+��`+��	`+��`+��`+�
>�`+�D@E�1+�l$�++�
�"�
++��++��++�
�++��
++�
�++�`!�#(�	� �
�����!�	�
$��@""�H�/��N�`#�)� �!��#����H�:�x�(��	�BG�	�)�	�:>�	�	�	���4�&��+��/�	�

��43�j�!��!�
����
�2�U��U�
�[�[� �� ����
�/�
	!� ��	+��
+�2�+��+��	+��
+�
�+�<��37��LP����+/��EI��	
��6�>A��"�#�
�(,�"'�U#���!�"�
�)U#�$�U#��U#�<�	U#�
�U#��
U#��U#�
�U#�&�U#� �U#��U#��U#� �!U#�"�#U#�$
�%U#�*
G�+U#�t�#(�!��!�9O�-�9O��9O�!�	9O�
�9O��
9O��9O�
�9O�z'�'7�8M�Od�'e�f�� ,�-=�#�%A�.�!��&�&6�7K�M`�&a�b��&�'7�8M�Od�'e�f�� �!1�/�>�!R�S�M��.�|�[�I�J�J�%�&6�8H�I�N��
�I�6�H�%�&6�8H�I�N�%�&6�8H�I�N�#�N�M�B�L�$�_�o�F�M��
�I�6�H�"�=�,�?�K�!�,��<�J�&�'8�:J�K�O�#�N�M�B�L�'�(:�<M�N��&�'8�:J�K�O�)�*>�@T�U��$�_�o�F�M�&�'8�:K�L�O��
�I�6�H��y�(�3�G� ��j�9�I��
�I�6�H�#�N�N�C�L��KrCc�@��eZdZdd�fd�
Zdd�Zd	d�Zd�Zd
d�Z�xZS)r�c�>��t�|��||_||_yr=)�superr��anchorr�)r�r�r�r�s   �r6r�z_PendingSkip.__init__=	s���
�������"��rCc�b�t|jt�z�jdd�S)Nr��...)rtr�r��replacers r6r,z!_PendingSkip._generateDefaultNameB	s%���4�;�;���(�)�1�1�'�5�A�ArCc�
��t|�jd�d�}�jrEd�}�fd�}�j|�j	|�z|�j	|�z|zS�j|z|zS)Nr�r�c��|jr|jj�dgk(r|d=|jdd�yy)Nrfr�_skipped)r�r��pop)r�s r6r�z'_PendingSkip.__add__.<locals>.must_skipI	s:���z�z�Q�Z�Z�%7�%7�%9�b�T�%A��!���E�E�*�d�+�&BrCc���|jj�dddgk(r%|jd�d�j�d�|d<yy)Nr�rfr�z	missing <r�)r�r�r�r�)r�r�s �r6�	show_skipz'_PendingSkip.__add__.<locals>.show_skipN	sH����:�:�%�%�'���,���4��E�E�*�%�&/�����a�$@�A�j�M�5rC)r�r1r�r�r>)r�r��skipperr�r�s`    r6r�z_PendingSkip.__add__E	s����/�&��-�(�(��/��<���>�>�
,�

A����g�i�8�8��C�C��)�,�,�Y�7�8���
�
�{�{�W�$�u�,�,rCc��|jSr=)r�rs r6r:z_PendingSkip.__repr__Z	s�����rCc��td��)NzBuse of `...` expression without following SkipTo target expression)r]rss  r6rTz_PendingSkip.parseImpl]	s���P�
�	
rCr�)r�rsr�rgrErFr�r�r�)	r)r*r+r�r,r�r:rT�
__classcell__�r�s@r6r�r�:	s���#�
B�-�* �
rCr�c�,��eZdZdZd�fd�Zdd�Z�xZS)�TokenzYAbstract :class:`ParserElement` subclass, for defining atomic
    matching patterns.
    c�&��t�|�d��y)NF�r�r�r��r�r�s �r6r�zToken.__init__h	s���
���%��(rCc�,�t|�jSr=)r�r)rs r6r,zToken._generateDefaultNamek	s���D�z�"�"�"rCrDr�)r)r*r+r,r�r,r�r�s@r6r�r�c	s����)�#rCr�c�.��eZdZdZd�fd�Zddd�Z�xZS)rz(
    A token that will never match.
    c�L��t�|��d|_d|_d|_y)NTFzUnmatchable token)r�r�r�r�r�r�s �r6r�zNoMatch.__init__t	s%���
����!%���"���)��rCc�2�t|||j|��r=)r�r�rSs    r6rTzNoMatch.parseImplz	s���X�s�D�K�K��>�>rCrDr�r��r)r*r+r,r�rTr�r�s@r6rro	s����*�?�?rCrc�X��eZdZdZd	dd�d
�fd�Zd�Zd	dd�d�fd�Zdd�Zd
dd�Z�xZ	S)rma�
    Token to exactly match a specified string.

    Example::

        Literal('abc').parse_string('abc')  # -> ['abc']
        Literal('abc').parse_string('abcdef')  # -> ['abc']
        Literal('abc').parse_string('ab')  # -> Exception: Expected "abc"

    For case-insensitive matching, use :class:`CaselessLiteral`.

    For keyword matching (force word break before and after the matched string),
    use :class:`Keyword` or :class:`CaselessKeyword`.
    rf��matchStringc���|tur<|xs|}|st�|�	t�St	|�dk(rt�|�	t
�St�|�	|�SrM)rmr��__new__r�rN�_SingleCharLiteral)r@�match_stringr�r�s   �r6r�zLiteral.__new__�	sT����'�>�&�6�,�L���w��u�-�-��<� �A�%��w��'9�:�:��w��s�#�#rCc��|jfSr=)�matchrs r6�__getnewargs__zLiteral.__getnewargs__�	s���
�
�}�rCc���t�|��|xs|}||_t|�|_|dd|_d|j��|_d|_d|_	y)Nrr0F)
r�r�rrN�matchLen�firstMatchCharrAr�r�r��r�rr�r�s   �r6r�zLiteral.__init__�	s\���
����"�2�l��!��
��L�)��
�*�2�A�.���!�$�)�)��-���!&���"��rCc�,�t|j�Sr=��reprrrs r6r,zLiteral._generateDefaultName�	����D�J�J��rCc���|||jk(r7|j|j|�r||jz|jfSt	|||j
|��r=)rr0rrr�r�rSs    r6rTzLiteral.parseImpl�	sY���C�=�D�/�/�/�H�4G�4G��J�J��5
�����&��
�
�2�2��X�s�D�K�K��>�>rC�rf)rrtr�rt�rrtr�rtrErFr�r�r�)
r)r*r+r,r�rr�r,rTr�r�s@r6rmrm~	s4���
�
$�2�
$��#�R�#� �?�?rCrmc�>��eZdZdZddd�d�fd�Zd	d�Zd
dd�Z�xZS)r�z,
    An empty token, will always match.
    rfr�c�@��t�|�d�d|_d|_y)NrfTF�r�r�r�r�rs   �r6r�zEmpty.__init__�	s ���
�����!%���"��rCc��y)Nr�rYrs r6r,zEmpty._generateDefaultName�	s��rCc�
�|gfSr=rYrSs    r6rTzEmpty.parseImpl�	rUrCr
rDr�r�r��r)r*r+r,r�r,rTr�r�s@r6r�r��	s#����#�r�#�
��rCr�c��eZdZddd�Zy)r�c�x�|||jk(r|dz|jfSt|||j|��rM)rrr�r�rSs    r6rTz_SingleCharLiteral.parseImpl�	s<���C�=�D�/�/�/���7�D�J�J�&�&��X�s�D�K�K��>�>rCNr�r�)r)r*r+rTrYrCr6r�r��	s��?rCr�c���eZdZdZedzZ			dddd�											d�fd�Zd
d�Zddd�Ze	dd	��Z
e	ed
e
��Z�xZ
S)�Keyworda�
    Token to exactly match a specified string as a keyword, that is,
    it must be immediately preceded and followed by whitespace or
    non-keyword characters. Compare with :class:`Literal`:

    - ``Literal("if")`` will match the leading ``'if'`` in
      ``'ifAndOnlyIf'``.
    - ``Keyword("if")`` will not; it will only match the leading
      ``'if'`` in ``'if x=1'``, or ``'if(y==2)'``

    Accepts two optional constructor arguments in addition to the
    keyword string:

    - ``ident_chars`` is a string of characters that would be valid
      identifier characters, defaulting to all alphanumerics + "_" and
      "$"
    - ``caseless`` allows case-insensitive matching, default is ``False``.

    Example::

        Keyword("start").parse_string("start")  # -> ['start']
        Keyword("start").parse_string("starting")  # -> Exception

    For case-insensitive matching, use :class:`CaselessKeyword`.
    z_$rfN�r��
identCharsc���t�|��|xs|}|�tj}|xs|}||_t|�|_|dd|_|jstd��dt|�j�d|j��|_d|_
d|_||_|r%|j!�|_|j!�}t%|�|_y)Nrz2null string passed to Keyword; use Empty() insteadr0� F)r�r�r�DEFAULT_KEYWORD_CHARSrrNrrr�r�r)rAr�r�r��caseless�upper�
caselessmatchr�r)r�r�ident_charsrr�rr�s      �r6r�zKeyword.__init__�	s����	�����.�;�
��� �6�6�J�"�2�l��!��
��L�)��
�*�2�A�.����"�"��Q�R�R�!�$�t�*�"5�"5�!6�a��	�	�{�C���!&���"��� ��
��!-�!3�!3�!5�D��#�)�)�+�J��j�/��rCc�,�t|j�Sr=r	rs r6r,zKeyword._generateDefaultName
rrCc��|jxsd}|}|jr�||||jzj�|jk(�rr|dk(s"||dz
j�|j
vrw|t
|�|jz
k\s,|||jzj�|j
vr||jz|jfS|dz
}||jz}n�|dz
}|dz
}n�|||jk(r|jdk(s|j|j|�r�|dk(s||dz
|j
vri|t
|�|jz
k\s|||jz|j
vr||jz|jfS|dz
}||jz}n
|dz
}|dz
}t||||��)Nrfrrz/, was immediately followed by keyword characterz7, keyword was immediately preceded by keyword characterz7, keyword was immediately followed by keyword character)r�rrrr rrNrrr0r�)r�r�r�r'r��errlocs      r6rTzKeyword.parseImpl

s������"������=�=���c�D�M�M�1�2�8�8�:�d�>P�>P�P��!�8�x��a��0�6�6�8����O��s�8�}�t�}�}�<�<�#�C�$�-�-�$7�8�>�>�@����W�"�T�]�]�2�D�J�J�>�>��O�O�F� �4�=�=�0�F��W�W�F� �1�W�F�
�S�M�T�0�0�0��
�
��"��"�"�4�:�:�s�3��a�x�8�C�!�G�,�D�O�O�C��3�x�=�4�=�=�8�8���d�m�m� 3�4�D�O�O�K�����.��
�
�:�:��S�S���t�}�}�,���S�S���q����X�v�v�t�<�<rCc��|t_y)zX
        Overrides the default characters used by :class:`Keyword` expressions.
        N)rr)r�s r6�set_default_keyword_charsz!Keyword.set_default_keyword_chars6
s��
).��%rC�setDefaultKeywordChars)rfNF)rrtr!r�rrgr�rtrr�rErFr�r�r�rD)r)r*r+r,r|rr�r,rTr�r&rr'r�r�s@r6rr�	s�����4&��,���,0��	*��+/�*��*�*�*��	*��
*�)�*�
�*�8 �*=�X�.��.�*��1�3L�M��rCrc�6��eZdZdZddd�d�fd�Zdd	d�Z�xZS)
�CaselessLiteralaq
    Token to match a specified string, ignoring case of letters.
    Note: the matched results will always be in the case of the given
    match string, NOT the case of the input text.

    Example::

        CaselessLiteral("CMD")[1, ...].parse_string("cmd CMD Cmd10")
        # -> ['CMD', 'CMD', 'CMD']

    (Contrast with example for :class:`CaselessKeyword`.)
    rfr�c���|xs|}t�|�|j��||_d|j��|_y)Nr0)r�r�r�returnStringrAr�rs   �r6r�zCaselessLiteral.__init__Q
s=���"�2�l��
����+�+�-�.�(���!�$�)�)��-��rCc���||||jzj�|jk(r||jz|jfSt	|||j
|��r=)rrrr+r�r�rSs    r6rTzCaselessLiteral.parseImplX
sV���C�#��
�
�-�.�4�4�6�$�*�*�D�����&��(9�(9�9�9��X�s�D�K�K��>�>rCr
rr�r�r�r�s@r6r)r)C
s����.�R�.�?�?rCr)c�D��eZdZdZ		dddd�									d�fd�Z�xZS)�CaselessKeywordz�
    Caseless version of :class:`Keyword`.

    Example::

        CaselessKeyword("CMD")[1, ...].parse_string("cmd CMD Cmd10")
        # -> ['CMD', 'CMD']

    (Contrast with example for :class:`CaselessLiteral`.)
    rfNrc�B��|xs|}|xs|}t�|�||d��y)NT)rr�)r�rr!r�rr�s     �r6r�zCaselessKeyword.__init__j
s-��� �.�;�
�"�2�l��
����z�D��ArC)rfN)
rrtr!r�r�rtrr�rErF�r)r*r+r,r�r�r�s@r6r.r.^
s_���	��,0�
B�
�+/�
B��
B�*�
B�
�
B�)�
B�
�
B�
BrCr.c�P��eZdZdZ	dddd�							d	�fd�Zd
d�Zddd�Z�xZS)
�
CloseMatcha�A variation on :class:`Literal` which matches "close" matches,
    that is, strings with at most 'n' mismatching characters.
    :class:`CloseMatch` takes parameters:

    - ``match_string`` - string to be matched
    - ``caseless`` - a boolean indicating whether to ignore casing when comparing characters
    - ``max_mismatches`` - (``default=1``) maximum number of
      mismatches allowed to count as a match

    The results from a successful parse will contain the matched text
    from the input string and the following named results:

    - ``mismatches`` - a list of the positions within the
      match_string where mismatches were found
    - ``original`` - the original match_string used to compare
      against the input string

    If ``mismatches`` is an empty list, then the match was an exact
    match.

    Example::

        patt = CloseMatch("ATCATCGAATGGA")
        patt.parse_string("ATCATCGAAXGGA") # -> (['ATCATCGAAXGGA'], {'mismatches': [[9]], 'original': ['ATCATCGAATGGA']})
        patt.parse_string("ATCAXCGAAXGGA") # -> Exception: Expected 'ATCATCGAATGGA' (with up to 1 mismatches) (at char 0), (line:1, col:1)

        # exact match
        patt.parse_string("ATCATCGAATGGA") # -> (['ATCATCGAATGGA'], {'mismatches': [[]], 'original': ['ATCATCGAATGGA']})

        # close match allowing up to 2 mismatches
        patt = CloseMatch("ATCATCGAATGGA", max_mismatches=2)
        patt.parse_string("ATCAXCGAAXGGA") # -> (['ATCAXCGAAXGGA'], {'mismatches': [[4, 9]], 'original': ['ATCATCGAATGGA']})
    rF)�
maxMismatchesrc���|�|n|}t�|��||_||_d|j�d|j�d�|_||_d|_d|_y)Nr0z
 (with up to z mismatches)F)r�r�rr3r�rr�r�)r�r�max_mismatchesr3rr�s     �r6r�zCloseMatch.__init__�
sh���+9�*D��-�
�
����(���*���!�$�"3�"3�!6�m�D�DV�DV�CW�Wc�d��� ��
�"���!&��rCc�J�t|�j�d|j��S)Nrc)r�r)rrs r6r,zCloseMatch._generateDefaultName�
s%���t�*�%�%�&�a��(9�(9�'<�=�=rCc��|}t|�}|t|j�z}||kr�|j}d}g}	|j}
tt	||||��D]]\}}|\}}
|j
r |j
�|
j
�}
}||
k7s�=|	j|�t|	�|
kDs�]n&||zdz}t|||g�}||d<|	|d<||fSt|||j|��)Nrr�original�
mismatches)rNrr3�	enumerate�ziprrhr
r r�r�)r�r�r�r'r�rO�maxlocr�match_stringlocr9r3�s_m�src�mat�resultss               r6rTzCloseMatch.parseImpl�
s�����x�=����T�.�.�/�/���X���,�,�L��O��J� �.�.�M�(1��H�S��(�,�7�)�
$�$������S��=�=�"�y�y�{�C�I�I�K��C��#�:��%�%�o�6��:���6��
$��o�-��1��&���s�(;�'<�=��&2��
�#�(2���%��G�|�#��X�s�D�K�K��>�>rCr=)rrtr5r�r3r�rErFr�r�r�rr�s@r6r2r2w
sU��� �J04�'�
��
'��'�-�'�
�'�
�'�">�?�?rCr2c���eZdZdZ							d	ddddd�																							d
�fd�Zdd�Zdd
d�Zdd
d�Z�xZS)�Worda>Token for matching words composed of allowed character sets.

    Parameters:

    - ``init_chars`` - string of all characters that should be used to
      match as a word; "ABC" will match "AAA", "ABAB", "CBAC", etc.;
      if ``body_chars`` is also specified, then this is the string of
      initial characters
    - ``body_chars`` - string of characters that
      can be used for matching after a matched initial character as
      given in ``init_chars``; if omitted, same as the initial characters
      (default=``None``)
    - ``min`` - minimum number of characters to match (default=1)
    - ``max`` - maximum number of characters to match (default=0)
    - ``exact`` - exact number of characters to match (default=0)
    - ``as_keyword`` - match as a keyword (default=``False``)
    - ``exclude_chars`` - characters that might be
      found in the input ``body_chars`` string but which should not be
      accepted for matching ;useful to define a word of all
      printables except for one or two characters, for instance
      (default=``None``)

    :class:`srange` is useful for defining custom character set strings
    for defining :class:`Word` expressions, using range notation from
    regular expression character sets.

    A common mistake is to use :class:`Word` to match a specific literal
    string, as in ``Word("Address")``. Remember that :class:`Word`
    uses the string argument to define *sets* of matchable characters.
    This expression would match "Add", "AAA", "dAred", or any other word
    made up of the characters 'A', 'd', 'r', 'e', and 's'. To match an
    exact literal string, use :class:`Literal` or :class:`Keyword`.

    pyparsing includes helper strings for building Words:

    - :class:`alphas`
    - :class:`nums`
    - :class:`alphanums`
    - :class:`hexnums`
    - :class:`alphas8bit` (alphabetic characters in ASCII range 128-255
      - accented, tilded, umlauted, etc.)
    - :class:`punc8bit` (non-alphabetic characters in ASCII range
      128-255 - currency, symbols, superscripts, diacriticals, etc.)
    - :class:`printables` (any non-whitespace character)

    ``alphas``, ``nums``, and ``printables`` are also defined in several
    Unicode sets - see :class:`pyparsing_unicode``.

    Example::

        # a word composed of digits
        integer = Word(nums) # equivalent to Word("0123456789") or Word(srange("0-9"))

        # a word with a leading capital, and zero or more lowercase
        capitalized_word = Word(alphas.upper(), alphas.lower())

        # hostnames are alphanumeric, with leading alpha, and '-'
        hostname = Word(alphas, alphanums + '-')

        # roman numeral (not a strict parser, accepts invalid mix of characters)
        roman = Word("IVXLCDM")

        # any string of non-whitespace characters, except for ','
        csv_value = Word(printables, exclude_chars=",")
    NF)�	initChars�	bodyChars�	asKeyword�excludeCharsc���|xs|}|	xs|}	|
xs|}
|xs|}t�|��|s"tdt|�j�d���t|�}|r/t|�}
||
z}|	rdj
t|	�|
z
�}	||_dj
t|��|_	|	r0t|	�|_
dj
t|	��|_n||_
|j|_|dkD|_|dkrtd��|jr||kDrtd|�d|�d	���||_
|dkDr||_nt|_|dkDr|x}}||_||_
d
|j ��|_d|_|
|_|j&r|xj"dz
c_d
|j|jzv�r�t)|j�dk(r t+j,|j�}ndt/|j��d�}|j|jk(r�|dk(r|jdk(rd}nd|dk(rd}n\|j|jk7r3d|j�d|jtk(rdn|j�d�}nd|j�d�}|�|��|_n�|dk(rd}d}nrdt/|j��d�}|dk(r|jdk(rd}nB|dk(r
|dkrdnd}n3||k7rd|dkDr|dz
nd�d|dkDr|dz
nd�d�}nd|dkDr|dz
nd�d�}|�|�|��|_|j&rd|j0�d�|_	t+j2|j0�|_|j*j4|_|j8|_yy#t*j<$r
d|_YywxYw)Nzinvalid z", initChars cannot be empty stringrfrrzUcannot specify a minimum length < 1; use Opt(Word()) if zero-length word is permittedzDinvalid args, if min and max both specified min must be <= max (min=z, max=rr0Fz
 as a keywordr�[r�+�{r��}rrS�?z\b)r�r�r�r�r)r�r�rD�sorted�
initCharsOrigrE�
bodyCharsOrig�maxSpecified�minLen�maxLenr�rAr�r�rFrN�re�escaper�reString�compiler�re_match�parseImpl_regexrT�error)r��
init_chars�
body_charsr��max�exact�
as_keyword�
exclude_charsrDrErFrG�
initChars_set�excludeChars_set�re_leading_fragment�repeat�re_body_fragmentr�s                 �r6r�z
Word.__init__s�����+��	��+��	��+��	�#�4�}��
�������4��:�.�.�/�/Q�R��
��I��
��"�<�0���-�-�M���G�G�C�	�N�5E�$E�F�	�&����W�W�V�M�%:�;���� ��^�D�N�!#����	�):�!;�D��*�D�N�!%�!3�!3�D���!�G�����7��g��
�����s���V�WZ�V[�[a�be�af�fg�h��
������7��D�K�"�D�K��1�9���C�#��D�K��D�K�!�$�)�)��-���"���"����>�>��K�K�?�*�K��t�~�~����6�7��4�>�>�"�a�'�&(�i�i��0B�0B�&C�#�()�*D�T�^�^�*T�)U�UV�&W�#��~�~����/��!�8����q� 0� �F��A�X��F��{�{�d�k�k�1�#%�d�k�k�]�!�$�+�+��:Q�B�W[�Wb�Wb�3c�ce�!f��#%�d�k�k�]�"�!5��#6�"7��x� @��
��!�8�')�$��F�)*�+E�d�n�n�+U�*V�VW�'X�$��a�x�D�K�K�1�$4�!$�����(+�q���b���#�:�')�S�1�W�#��'�"�)E�Q�RU�XY�RY�s�Q�w�_a�Fb�bd�%e�F�')�S�1�W�#��'�"�)E�R�%H�F�#6�"7�8H�7I�&�� R��
��~�~�#%�d�m�m�_�B� 7��
�
6��*�*�T�]�]�3���!%���
�
��
�!%�!5�!5���Y8��P�8�8�
����
�s�&$N8�8O�Oc��d�}|j|jk7r*d||j��d||j��d�}nd||j��d�}|jdkDs|jtk7r�|j|jk(r'|jdk(r|ddS|d|j�d�zS|jtk(r|d|j�d	�zS|d|j�d
|j�d�zS|S)Nc�V�d}t|d��}t|�|kDr|d|dz
dzS|S)N�F)�	re_escaperTr�)rrN)r��max_repr_lens  r6�
charsAsStrz-Word._generateDefaultName.<locals>.charsAsStr�s<���L�*�1��>�A��1�v��$��+�<�!�+�,�u�4�4��HrCzW:(�, rrrSrKrLz,...}r�)rDrErRrSr�)r�rk�bases   r6r,zWord._generateDefaultName�s���	��>�>�T�^�^�+���D�N�N�3�4�B�z�$�.�.�7Q�6R�RS�T�D���D�N�N�3�4�A�6�D��;�;��?�d�k�k�X�5��{�{�d�k�k�)��;�;�!�#����8�O��B�t�{�{�m�2�"6�6�6�����(���4�;�;�-�v�6�6�6���4�;�;�-�q����
�R�@�@�@��rCc��|||jvrt|||j|��|}|dz
}t|�}|j}||j
z}t
||�}||kr|||vr|dz
}||kr|||vr�d}||z
|jkrd}nD|jr||kr
|||vrd}n)|jr|dkDr
||dz
|vs||kr	|||vrd}|rt|||j|��||||fS)NrFTr)
rDr�r�rNrErSr�rRrQrF)	r�r�r�r'r�rOr\r<�throw_exceptions	         r6rTzWord.parseImpl�s*���C�=����.� ��3����T�B�B����q����x�=��#�~�~�
�����$���V�X�&���F�l�x��}�
�:��1�H�C��F�l�x��}�
�:� ����;����$�"�O�
�
�
�3��>�h�s�m�z�6Q�"�O�
�^�^�
�Q�Y�8�E�A�I�.�*�<��h��8�C�=�J�#>�"�O�� ��3����T�B�B��H�U�3�'�'�'rCc��|j||�}|st|||j|��|j�}||j	�fSr=)rXr�r�r��group)r�r�r�r'r�s     r6rYzWord.parseImpl_regex�sF�����x��-��� ��3����T�B�B��j�j�l���F�L�L�N�"�"rC)rfNrrrFN)r[rtr\r�r�r�r]r�r^r�r_rgr`r�rDr�rEr�rFrgrGr�rErFr�r�r�)	r)r*r+r,r�r,rTrYr�r�s@r6rCrC�
s����@�H�+/���� �.2�t6�+/�*.��-1�t6��t6�)�t6��	t6�
�t6��
t6��t6�,�t6�(�t6�(�t6��t6�+�t6�
�t6�l�8(�:#�#rCrCc�H��eZdZdZ		dddd�											d�fd�Z�xZS)�Charz�A short-cut class for defining :class:`Word` ``(characters, exact=1)``,
    when defining a match of any single character in a string of
    characters.
    FN)rFrGc�D��|xs|}|xs|}t�|�|d||��y)Nr)r^r_r`r�)r��charsetr_r`rFrGr�s      �r6r�z
Char.__init__�s4����+��	�#�4�}��
����1��,�	�	
rC)FN)rurtr_rgr`r�rFrgrGr�rErFr0r�s@r6rsrs�sa����!�.2�	

� �-1�

��

��

�,�	

��


�+�

�
�

�

rCrsc����eZdZdZ			dddd�													d�fd�Zedd��Zedd��Zed��Z	e	jd��Z	dd	�Zddd
�Zdd�Z
dd�Zdd
�Z�xZS)�Regexa�Token for matching strings that match a given regular
    expression. Defined with string specifying the regular expression in
    a form recognized by the stdlib Python  `re module <https://docs.python.org/3/library/re.html>`_.
    If the given regex contains named groups (defined using ``(?P<name>...)``),
    these will be preserved as named :class:`ParseResults`.

    If instead of the Python stdlib ``re`` module you wish to use a different RE module
    (such as the ``regex`` module), you can do so by building your ``Regex`` object with
    a compiled RE that was compiled using ``regex``.

    Example::

        realnum = Regex(r"[+-]?\d+\.\d*")
        # ref: https://stackoverflow.com/questions/267399/how-do-you-match-only-valid-roman-numerals-with-a-regular-expression
        roman = Regex(r"M{0,4}(CM|CD|D?{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})")

        # named fields in a regex will be returned as named results
        date = Regex(r'(?P<year>\d{4})-(?P<month>\d\d?)-(?P<day>\d\d?)')

        # the Regex class will accept re's compiled using the regex module
        import regex
        parser = pp.Regex(regex.compile(r'[0-9]'))
    F)�asGroupList�asMatchc�Z��t�|��|xs|}|xs|}t|t�r*|st	d��d|_d|_|x|_|_nkt|d�r3t|d�r'||_d|_|jx|_|_n,t|�r||_d|_d|_ntd��||_d|j��|_d|_||_||_|j r|j$|_|j"r|j(|_yy)aThe parameters ``pattern`` and ``flags`` are passed
        to the ``re.compile()`` function as-is. See the Python
        `re module <https://docs.python.org/3/library/re.html>`_ module for an
        explanation of the acceptable patterns and flags.
        z0null string passed to Regex; use Empty() insteadN�patternrz�Regex may only be constructed with a string or a compiled RE object, or a callable that takes no arguments and returns a string or a compiled RE objectr0F)r�r�r^r#r��_rer�rVr{r.r3r��flagsrAr�r�rxry�parseImplAsGroupListrT�parseImplAsMatch)r�r{r}�
as_group_list�as_matchrxryr�s       �r6r�zRegex.__init__�s!���	����!�2�]���%�X���g�x�(�� �!S�T�T��D�H�%)�D�"�+2�2�D�M�D�L�
�W�i�
(�W�W�g�-F��D�H�%)�D�"�+2�?�?�:�D�L�4�=�
�g�
�"�D�L�%)�D�"��D�H��&��
���
�!�$�)�)��-���"���&���������!�6�6�D�N��<�<�!�2�2�D�N�rCc���|jr|jSt|j�r�ttgt
f|j��|_t
|jd�rtt
|jd�r^ttjt
|j�|_|jjx|_|_	|jS	tj|j|j�|_|jjdd��du|_
|jS#tj$rtd|j�d���wxYw)Nr{rrfr)�poszinvalid pattern (z) passed to Regex)r|r3r{rrrtr.rT�PatternrVrWr}rr�rZr�rs r6rTzRegex.re/s���8�8��8�8�O��D�L�L�!�@�4���S�� 1�4�<�<�@�B�D�L��t�|�|�Y�/�G�D�L�L�'�4R���
�
�3�����>���/3�x�x�/?�/?�?���t�}��x�x��	��z�z�$�,�,��
�
�;�D�H�&*�W�W�]�]�2�1�]�%=�T�%I�D�"��8�8�O��	�x�x�	T��0����0@�@Q�R�S�S�	T�s�&/E�-E2c�.�|jjSr=)rTrrs r6rXzRegex.re_matchFs���w�w�}�}�rCc�J�|j�|j|jSr=)r�rTrs r6rzRegex.mayReturnEmptyJs!���!�!�)��G�G��%�%�%rCc��||_yr=rr	s  r6rzRegex.mayReturnEmptyQrrCc�X�t|j�jdd�}d|�d�S)Nz\\�\zRe:(r)r
r{r�)r��	unescapeds  r6r,zRegex._generateDefaultNameUs,������&�.�.�v�t�<�	��i�[��"�"rCc�r�|t|�kDr$|jrt|||j|��|j	||�}|st|||j|��|j�}t
|j��}|j�}|j�D]
\}}|||<�||fSr=)
rNrr�r�rXr�r rq�	groupdict�items)	r�r�r�r'r�r��d�k�vs	         r6rTzRegex.parseImplYs�����X���4�#6�#6� ��3����T�B�B����x��-��� ��3����T�B�B��j�j�l���6�<�<�>�*��������G�G�I�	�D�A�q��C��F�	��C�x�rCc��|t|�kDr$|jrt|||j|��|j	||�}|st|||j|��|j�}|j
�}||fSr=)rNrr�r�rXr��groups�r�r�r�r'r�r�s      r6r~zRegex.parseImplAsGroupListmsr����X���4�#6�#6� ��3����T�B�B����x��-��� ��3����T�B�B��j�j�l���m�m�o���C�x�rCc���|t|�kDr$|jrt|||j|��|j	||�}|st|||j|��|j�}|}||fSr=)rNrr�r�rXr�r�s      r6rzRegex.parseImplAsMatchysl����X���4�#6�#6� ��3����T�B�B����x��-��� ��3����T�B�B��j�j�l�����C�x�rCc������jrtd���jrt��rtd���jr�fd�}n��fd�}�j	|�S)a�
        Return :class:`Regex` with an attached parse action to transform the parsed
        result as if called using `re.sub(expr, repl, string) <https://docs.python.org/3/library/re.html#re.sub>`_.

        Example::

            make_html = Regex(r"(\w+):(.*?):").sub(r"<\1>\2</\1>")
            print(make_html.transform_string("h1:main title:"))
            # prints "<h1>main title</h1>"
        z/cannot use sub() with Regex(as_group_list=True)z:cannot use sub() with a callable with Regex(as_match=True)c�,��|dj��Sr�)�expand)rc�repls �r6r�zRegex.sub.<locals>.pa�s����a�y�'�'��-�-rCc�B���jj�|d�Sr�)rT�sub)rcr�r�s ��r6r�zRegex.sub.<locals>.pa�s����w�w�{�{�4����3�3rC)rxr�ryr3r>)r�r�r�s`` r6r�z	Regex.sub�s]�������M�N�N��<�<�H�T�N��L��
��<�<�
.�

4��$�$�R�(�(rC)rFF)r{rr}zUnion[re.RegexFlag, int]r�rgr�rgrxrgryrgrErF)rEz
re.Pattern)rEzCallable[[str, int], Any]r�r�r�)r�rtrErs)r)r*r+r,r�r$rTrXr�rr�r,rTr~rr�r�r�s@r6rwrw�s�����6+,�#��53�"��53��53�(�53��	53�
�53��53��53�
�53�n����,�����&��&����'��'�#��(
�
�)rCrwc���eZdZdZed�Z							d
ddddddd�																											d�fd�Zdd�Zd
dd	�Z�xZ	S)�QuotedStringa
    Token for matching strings that are delimited by quoting characters.

    Defined with the following parameters:

    - ``quote_char`` - string of one or more characters defining the
      quote delimiting string
    - ``esc_char`` - character to re_escape quotes, typically backslash
      (default= ``None``)
    - ``esc_quote`` - special quote sequence to re_escape an embedded quote
      string (such as SQL's ``""`` to re_escape an embedded ``"``)
      (default= ``None``)
    - ``multiline`` - boolean indicating whether quotes can span
      multiple lines (default= ``False``)
    - ``unquote_results`` - boolean indicating whether the matched text
      should be unquoted (default= ``True``)
    - ``end_quote_char`` - string of one or more characters defining the
      end of the quote delimited string (default= ``None``  => same as
      quote_char)
    - ``convert_whitespace_escapes`` - convert escaped whitespace
      (``'\t'``, ``'\n'``, etc.) to actual whitespace
      (default= ``True``)

    Example::

        qs = QuotedString('"')
        print(qs.search_string('lsjdf "This is the quote" sldjf'))
        complex_qs = QuotedString('{{', end_quote_char='}}')
        print(complex_qs.search_string('lsjdf {{This is the "quote"}} sldjf'))
        sql_qs = QuotedString('"', esc_quote='""')
        print(sql_qs.search_string('lsjdf "This is the quote with ""embedded"" quotes" sldjf'))

    prints::

        [['This is the quote']]
        [['This is the "quote"']]
        [['This is the quote with "embedded" quotes']]
    ))z\t�	)rerf)z\f�)z\r�
rfNT)�	quoteChar�escChar�escQuote�unquoteResults�endQuoteChar�convertWhitespaceEscapesc����t����|	xs|}|
xs|}|xr|}|xs|}|
xr|}|xs|}|j�}|std��|�|}n|j�}|std��|�_t|��_|d�_|�_t|��_	|xsd�_
|du�_|xsd�_|�_
|�_|�_t!j"d��_g}|r(|j'dt!j(|��d��|r(|j'dt!j(|��d��t�j�dkDrP|j'dd	j+�fd
�t-t�j�dz
dd�D��zdz��jr��xj$t j.t j0zzc_|j'dt3�jd���jrt3�j�nd�d
��nO|j'dt3�jd��d�jrt3�j�nd�d
��dj+t!j(�j�dd	j+|�dt!j(�j�g��_�jrljjrtt!j6dd	j+d��j8D���dd�dd�dd�dt!j(�j��d��j$���_nGt!j6dt!j(�j��d��j$���_	t!j6�j4�j$��_�j4�_�j j>�_ d�jD���_#d�_$d�_%y#t jB$rtd�j4�d���wxYw) Nz%quote_char cannot be the empty stringz)end_quote_char cannot be the empty stringrrf�(?:rz.)r�|c	3��K�|]M}dtj�jd|��dtj�j|d��d����Oy�w)r�Nz(?!z)))rTrU�end_quote_char)r4rdr�s  �r6r�z(QuotedString.__init__.<locals>.<genexpr>
sY��������"�)�)�D�$7�$7���$;�<�=�S����4�K^�K^�_`�_a�Kb�Ac�@d�df�g��s�AAr�z(?:[^z])z\n\rz)*r�c3�FK�|]}tj|����y�wr=)rTrU)r4r�s  r6r�z(QuotedString.__init__.<locals>.<genexpr>0
s����!D�1�"�)�)�A�,�!D�s�!z
)|(\\[0-7]rTz|\\0|\\x[0-9a-fA-F]rSz|\\u[0-9a-fA-F]rUz)|(z	.)|(\n|.)�r}zinvalid pattern z passed to Regexr0FT)&r�r�rjr��
quote_charrN�quote_char_len�first_quote_charr��end_quote_char_len�esc_char�has_esc_char�	esc_quote�unquote_results�convert_whitespace_escapes�	multilinerT�	RegexFlag�re_flagsr
rUr��range�	MULTILINE�DOTALLrr{rW�ws_map�unquote_scan_rerVrrXrZrAr�r�r�)r�r�r�r�r�r�r�r�r�r�r�r�r�r��
inner_patternr�s`              �r6r�zQuotedString.__init__�s ���"	�����&�h���)�	�	�(�<�_��%�7���$�C�)C�	#��,�*�
� �%�%�'�
���D�E�E��!�'�N�+�1�1�3�N�!� �!L�M�M�)���#&�z�?���%/��]���#1���'*�>�':���%�^���
�"*�$�"6���'�o�2���%4���0J��'�"������Q���
�$&�
��� � �C��	�	�)�(<�'=�Q�!?�@��� � �C��	�	�(�(;�'<�B�!?�@��t�"�"�#�a�'�� � ���(�(��"�3�t�':�':�#;�a�#?��B�G����
��
��>�>��M�M�R�\�\�B�I�I�5�5�M�� � ��2�4�3F�3F�q�3I�J�K�AE�AR�AR�.�t�}�}�=�XZ�\�\^�`�
�

� � ��2�4�3F�3F�q�3I�J�K�4�AE�AR�AR�.�t�}�}�=�XZ�\�\^�`�
�
�w�w��	�	�$�/�/�*������'���	�	�$�-�-�.�
�
�������.�.�')�z�z�����!D����!D�D�E�F!�!"��#6�q�c����L��)�)�D�M�M�2�3�4� ��-�-�(��$�(*�z�z�����4�=�=�1�2�3� ��-�-�(��$�	R��j�j����t�}�}�=�D�G� �L�L�D�M� �G�G�M�M�D�M�"�$�)�)��-���"���!%�����x�x�	R��/����/?�?O�P�Q�Q�	R�s
�AQ�-Q9c��|j|jk(r)t|jt�rd|j��Sd|j�d|j��S)Nzstring enclosed in zquoted string, starting with z
 ending with )r�r�r^r#rs r6r,z!QuotedString._generateDefaultNameI
sW���?�?�d�1�1�1�j��O�O�X�7
�)����(;�<�<�.�t���.?�}�T�M`�M`�La�b�brCc����||�jk(xr�j||�xsd}|st||�j���|j	�}|j�}dd���jr�|�j�j}t|t�r��jr5dj��fd��jj|�D��}n1djd��jj|�D��}�jr&|j!�j�j"�}||fS)Nc���|dk(ry|j�r$t|�dk(rtt|d���S|j	d�rtt|ddd���S|S)	N�0�rT�)rm)�u�xrrh)�isdigitrN�chrr�r0)r�s r6�convert_escaped_numericsz8QuotedString.parseImpl.<locals>.convert_escaped_numerics`
sY���C�x���y�y�{�s�1�v��{��3�q�q�>�*�*����j�)��3�q���u�2�.�/�/��rCrfc3�>�K�|]�}|jd�r�j|jd�n`|jd�r�|jd�dd�n5|jd�r|jd�dn|jd�����y�w)rrSNrTr�rU)rqr�)r4rr�r�s  ��r6r�z)QuotedString.parseImpl.<locals>.<genexpr>t
s������"�"�8=�{�{�1�~����E�K�K��N�3�NS�[�[�YZ�^�5�e�k�k�!�n�Q�R�6H�I�38�;�;�q�>�U�[�[��^�B�/�"�[�[��^�,�"�s�BBc3�K�|]:}|jd�r|jd�dn|jd����<y�w)rr�rSN)rq)r4rs  r6r�z)QuotedString.parseImpl.<locals>.<genexpr>�
sA����"�
"�/4�k�k�!�n����A��r�*�"�[�[��^�,�"�s�AA�r�rtrErt)r�rXr�r�r�rqr�r�r�r^r#r�r�r��finditerr�r�r�)r�r�r�r'r�r�r�s`     @r6rTzQuotedString.parseImplQ
s3���
�S�M�T�2�2�2�
-��
�
�h��,�
��	�
� ��3����T�B�B��j�j�l���l�l�n��	�����d�)�)�T�-D�-D�,D�E�C��#�x�(��2�2��'�'�"�&*�%9�%9�%B�%B�3�%G�"��C��'�'�"�
&*�%9�%9�%B�%B�3�%G�"��C��>�>��+�+�d�n�n�d�6I�6I�J�C��C�x�rC)rfNNFTNT)r�rtr�r�r�r�r�rgr�rgr�r�r�rgr�rtr�r�r�r�r�rgr�r�r�rgrErFr�r�r�)
r)r*r+r,r�r�r�r,rTr�r�s@r6r�r��s����%�N�N�
O�F��)-�*.�� $�/3�+/�x&��(,�)-�#�-1�)-�x&��x&�'�x&�(�	x&�
�x&��
x&�-�x&�%)�x&��x&�&�x&�'�x&��x&�+�x&�#'�x&� 
�!x&�tc�=�=rCr�c�\��eZdZdZ				ddd�											d�fd�Zd	d�Zd
dd�Z�xZS)�
CharsNotIna�Token for matching words composed of characters *not* in a given
    set (will include whitespace in matched characters if not listed in
    the provided exclusion set - see example). Defined with string
    containing all disallowed characters, and an optional minimum,
    maximum, and/or exact length.  The default value for ``min`` is
    1 (a minimum value < 1 is not valid); the default values for
    ``max`` and ``exact`` are 0, meaning no maximum or exact
    length restriction.

    Example::

        # define a comma-separated-value as anything that is not a ','
        csv_value = CharsNotIn(',')
        print(DelimitedList(csv_value).parse_string("dkls,lsdkjf,s12 34,@!#,213"))

    prints::

        ['dkls', 'lsdkjf', 's12 34', '@!#', '213']
    rf)�notCharsc�\��t�|��d|_|xs||_t	|j�|_|dkrt
d��||_|dkDr||_nt|_|dkDr||_||_d|j��|_|jdk(|_d|_
y)NFrzacannot specify a minimum length < 1; use Opt(CharsNotIn()) if zero-length char group is permittedrr0)r�r�r�r�r��notCharsSetr�rRrSr�rAr�r�r�)r��	not_charsr�r]r^r�r�s      �r6r�zCharsNotIn.__init__�
s����	����#���!�-�X��
��t�}�}�-�����7��L��
�
�����7��D�K�"�D�K��1�9��D�K��D�K�!�$�)�)��-���!%����!1���"��rCc��t|j�}t|�dkDrd|jdd�d�Sd|j�d�S)Nrhz!W:(�
z...)r)rr�rN)r��
not_chars_strs  r6r,zCharsNotIn._generateDefaultName�
sK��2�4�=�=�A�
��}���"��$�-�-��&�1�2�$�7�7��$�-�-���*�*rCc�H�|j}|||vrt|||j|��|}|dz
}t||jzt|��}||kr|||vr|dz
}||kr|||vr�||z
|jkrt|||j|��||||fSrM)r�r�r�r�rSrNrR)r�r�r�r'�notcharsr��maxlens       r6rTzCharsNotIn.parseImpl�
s����#�#���C�=�H�$� ��3����T�B�B����q����U�T�[�[�(�#�h�-�8���F�l�x��}�H�<��1�H�C��F�l�x��}�H�<���;����$� ��3����T�B�B��H�U�3�'�'�'rC)rfrrr)r�rtr�r�r]r�r^r�r�rtrErFr�r�r�rr�s@r6r�r��
so����,����!#��!#��!#��!#��	!#�
�!#��!#�
�!#�F+�(�(rCr�c����eZdZdZidd�dd�dd�dd	�d
d�dd
�dd�dd�dd�dd�dd�dd�dd�dd�dd�d d!�d"d#�d$d%d&d'd(d)d*��Z	d.									d/�fd+�
Zd0d,�Zd1d2d-�Z�xZS)3�Whitea�Special matching class for matching whitespace.  Normally,
    whitespace is ignored by pyparsing grammars.  This class is included
    when some whitespace structures are significant.  Define with
    a string containing the whitespace characters to be matched; default
    is ``" \t\r\n"``.  Also takes optional ``min``,
    ``max``, and ``exact`` arguments, as defined for the
    :class:`Word` class.
    rz<SP>r�z<TAB>rfz<LF>r�z<CR>r�z<FF>� z<NBSP>u z<OGHAM_SPACE_MARK>u᠎z<MONGOLIAN_VOWEL_SEPARATOR>u z	<EN_QUAD>u z	<EM_QUAD>u z
<EN_SPACE>u z
<EM_SPACE>u z<THREE-PER-EM_SPACE>u z<FOUR-PER-EM_SPACE>u z<SIX-PER-EM_SPACE>u z<FIGURE_SPACE>u z<PUNCTUATION_SPACE>z<THIN_SPACE>z<HAIR_SPACE>z<ZERO_WIDTH_SPACE>z<NNBSP>z<MMSP>z<IDEOGRAPHIC_SPACE>)u u u​u u u c�8���t����|�_�jdj	�fd��j
D��d��d�_d�j���_|�_	|dkDr|�_
nt�_
|dkDr|�_
|�_	yy)Nrfc3�@�K�|]}|�jvs�|���y�wr=)�
matchWhite)r4�cr�s  �r6r�z!White.__init__.<locals>.<genexpr>s�����J�!��$�/�/�1I�A�J�s��T�rr0r)r�r�r�rr��	whiteStrsr�rAr�rRrSr�)r��wsr�r]r^r�s`    �r6r�zWhite.__init__s����	��������!�!��G�G�J�t�~�~�J�J��	"�	
�
"&���!�$�)�)��-��������7��D�K�"�D�K��1�9��D�K��D�K�rCc�F�djd�|jD��S)Nrfc3�BK�|]}tj|���y�wr=)r�r��r4r�s  r6r�z-White._generateDefaultName.<locals>.<genexpr>s����C�a�u���q�)�C�s�)r�r�rs r6r,zWhite._generateDefaultNames���w�w�C�4�?�?�C�C�CrCc�p�|||jvrt|||j|��|}|dz
}||jz}t	|t|��}||kr-|||jvr|dz
}||kr|||jvr�||z
|jkrt|||j|��||||fSrM)r�r�r�rSr�rNrR)r�r�r�r'r�r<s      r6rTzWhite.parseImpl s����C�=����/� ��3����T�B�B����q�������$���V�S��]�+���F�l�x��}����?��1�H�C��F�l�x��}����?���;����$� ��3����T�B�B��H�U�3�'�'�'rC)z 	
rrr)
r�rtr�r�r]r�r^r�rErFr�r�r�)	r)r*r+r,r�r�r,rTr�r�s@r6r�r��
s;������V���g��	
�f��	
�f�	�
	
�f��	�(�
�	�&��	�/��	�+��	�+��	�,��	�,��	�(��	�'��	�&�� 	�"�!�"	�'�#�$!� �&���'�/�I�6MN� �� �(+� �69� �FI� �	
� �0D�
(�
(rCr�c� ��eZdZd�fd�Z�xZS)�
PositionTokenc�>��t�|��d|_d|_yrDrr�s �r6r�zPositionToken.__init__1s���
����!%���"��rCrD�r)r*r+r�r�r�s@r6r�r�0s
���#�#rCr�c�6��eZdZdZd�fd�Zdd�Zddd�Z�xZS)	�
GoToColumnzaToken to advance to a specific column of input text; useful for
    tabular report scraping.
    c�0��t�|��||_yr=)r�r�r�)r��colnor�s  �r6r�zGoToColumn.__init__<s���
������rCc�^�t||�|jk(r|St|�}|jr|j||�}||krc||j	�rPt||�|jk7r7|dz
}||kr-||j	�rt||�|jk7r�7|SrM)r�rNr�rK�isspace)r�r�r�rOs    r6rQzGoToColumn.preParse@s����s�H�����)��J��x�=������&�&�x��5�C��(�N���
�%�%�'��C��"�d�h�h�.��1�H�C�	
�(�N���
�%�%�'��C��"�d�h�h�.��
rCc��t||�}||jkDrt||d|��||jz|z
}|||}||fS)NzText not in expected column)r�r�)r�r�r�r'�thiscol�newlocr�s       r6rTzGoToColumn.parseImplPsT���c�8�$���T�X�X�� ��3�0M�t�T�T��t�x�x��'�)���s�6�"���s�{�rC)r�r�rErFr�r�r��r)r*r+r,r�rQrTr�r�s@r6r�r�7s������ �rCr�c�6��eZdZdZd�fd�Zdd�Zddd�Z�xZS)	�	LineStarta�Matches if current position is at the beginning of a line within
    the parse string

    Example::

        test = '''\
        AAA this line
        AAA and this line
          AAA but not this one
        B AAA and definitely not this one
        '''

        for t in (LineStart() + 'AAA' + rest_of_line).search_string(test):
            print(t)

    prints::

        ['AAA', ' this line']
        ['AAA', ' and this line']

    c�"��t�|��|j�t�|jz|_|jj
d�t�j|j�|_	|jd�y)Nrfz
start of line)r�r�rr�r��orig_whiteChars�discardr�rr�r1r�s �r6r�zLineStart.__init__psc���
��������"�u�t���6���������%��w�3�3�D�O�O�D����
�
�o�&rCc���|dk(r|S|jj||�}d|jvr6|||dzdk(r+|jj||dz�}|||dzdk(r�+|S)Nrrfr)r�rQr�)r�r�r�r�s    r6rQzLineStart.preParsexs{���!�8��J��l�l�#�#�H�c�2���4�'�'�'��3��q��)�T�1��l�l�+�+�H�c�A�g�>���3��q��)�T�1��
rCc�X�t||�dk(r|gfSt|||j|��rM)r�r�r�rSs    r6rTzLineStart.parseImpl�s/���s�H���"���7�N��X�s�D�K�K��>�>rCrDr�r�r�r�r�s@r6r�r�Ys����,'�
�?�?rCr�c�.��eZdZdZd�fd�Zddd�Z�xZS)�LineEndzTMatches if current position is at the end of a line within the
    parse string
    c���t�|��|jjd�|j	|jd��|jd�y)NrfFr�zend of line)r�r�r�r�rr1r�s �r6r�zLineEnd.__init__�sC���
����������%��!�!�$�/�/��!�G��
�
�m�$rCc���|t|�kr'||dk(r|dzdfSt|||j|��|t|�k(r|dzgfSt|||j|��)Nrfr�rNr�r�rSs    r6rTzLineEnd.parseImpl�sl����X�����}��$��Q�w��}�$�$�X�s�D�K�K��F�F�
�C��M�
!���7�B�;�� ��3����T�B�BrCrDr�r�r�r�s@r6r�r��s����%�	C�	CrCr�c�.��eZdZdZd�fd�Zddd�Z�xZS)�StringStartzLMatches if current position is at the beginning of the parse
    string
    c�D��t�|��|jd�y)Nz
start of text�r�r�r1r�s �r6r�zStringStart.__init__�s���
�����
�
�o�&rCc�n�|dk7r-||j|d�k7rt|||j|��|gfSr�)rQr�r�rSs    r6rTzStringStart.parseImpl�s9���!�8��t�}�}�X�q�9�9� ��3����T�B�B��B�w�rCrDr�r�r�r�s@r6rr�s����'��rCrc�.��eZdZdZd�fd�Zddd�Z�xZS)r�zG
    Matches if current position is at the end of the parse string
    c�D��t�|��|jd�y)Nzend of textrr�s �r6r�zStringEnd.__init__�s���
�����
�
�m�$rCc���|t|�krt|||j|��|t|�k(r|dzgfS|t|�kDr|gfSt|||j|��rMrrSs    r6rTzStringEnd.parseImpl�sg����X��� ��3����T�B�B��#�h�-����7�B�;����X�����7�N��X�s�D�K�K��>�>rCrDr�r�r�r�s@r6r�r��s����%�?�?rCr�c�B��eZdZdZefed�					d�fd�Zddd�Z�xZS)�	WordStarta�Matches if the current position is at the beginning of a
    :class:`Word`, and is not preceded by any character in a given
    set of ``word_chars`` (default= ``printables``). To emulate the
    ```` behavior of regular expressions, use
    ``WordStart(alphanums)``. ``WordStart`` will also match at
    the beginning of the string being parsed, or at the beginning of
    a line.
    ��	wordCharsc�~��|tk(r|n|}t�|�	�t|�|_|jd�y)Nzstart of a word)r}r�r�r�r
r1�r��
word_charsr
r�s   �r6r�zWordStart.__init__�s6���#,�z�"9�J�y�	�
�����Y�����
�
�'�(rCc��|dk7r=||dz
|jvs|||jvrt|||j|��|gfS�Nrr)r
r�r�rSs    r6rTzWordStart.parseImpl�sL���!�8���q��!�T�^�^�3��C�=����6�$�X�s�D�K�K��F�F��B�w�rC�rrtr
rtrErFr�r��r)r*r+r,r}r�rTr�r�s@r6rr�s<����!+�)�@J�)��)�:=�)�	
�)��rCrc�B��eZdZdZefed�					d�fd�Zddd�Z�xZS)�WordEndaiMatches if the current position is at the end of a :class:`Word`,
    and is not followed by any character in a given set of ``word_chars``
    (default= ``printables``). To emulate the ```` behavior of
    regular expressions, use ``WordEnd(alphanums)``. ``WordEnd``
    will also match at the end of the string being parsed, or at the end
    of a line.
    rc���|tk(r|n|}t�|�	�t|�|_d|_|j
d�y)NFz
end of a word)r}r�r�r�r
r�r1rs   �r6r�zWordEnd.__init__�s=���#,�z�"9�J�y�	�
�����Y����#����
�
�o�&rCc��t|�}|dkDrB||kr=|||jvs||dz
|jvrt|||j|��|gfSr)rNr
r�r�)r�r�r�r'rOs     r6rTzWordEnd.parseImpl�s[���x�=���a�<�C�(�N���
����/��C�!�G�$�D�N�N�:�$�X�s�D�K�K��F�F��B�w�rCrr�r�rr�s@r6rr�s<����!+�'�@J�'��'�:=�'�	
�'��rCrc�6��eZdZdZdd�fd�
Zdd�Zdd�Z�xZS)	�Tagax
    A meta-element for inserting a named result into the parsed
    tokens that may be checked later in a parse action or while
    processing the parsed results. Accepts an optional tag value,
    defaulting to `True`.

    Example::

        end_punc = "." | ("!" + Tag("enthusiastic")))
        greeting = "Hello," + Word(alphas) + end_punc

        result = greeting.parse_string("Hello, World.")
        print(result.dump())

        result = greeting.parse_string("Hello, World!")
        print(result.dump())

    prints::

        ['Hello,', 'World', '.']

        ['Hello,', 'World', '!']
        - enthusiastic: True
    c���t�|��d|_d|_|j	�||_||_|j|j�d|_	yrD)
r�r�r�r�r�tag_name�	tag_valuer>�_add_tagr)r�rr
r�s   �r6r�zTag.__init__sR���
����!%���"������� ��
�������d�m�m�,�$��rCc�6�|j||j<yr=)rr)r�rcs  r6rzTag._add_tag#s�� $����t�}�}�rCc�d�t|�j�d|j�d|j��S)Nrc�=)r�r)rrrs r6r,zTag._generateDefaultName&s-���t�*�%�%�&�a��
�
��a����7I�J�JrCr�)rrtr
rrErF)rcr r�)r)r*r+r,r�rr,r�r�s@r6rr�s����2%�/�KrCrc����eZdZdZ	d					d�fd�
Zdd�Zdd�Zdd�fd�
Zdd�fd�
Zd�fd�Z	dd�Z
d�fd	�Zddd
�Zd�fd�Z
dd�fd�
Zed
e�Zede�Z�xZS)�ParseExpressionz]Abstract subclass of ParserElement, for combining and
    post-processing parsed tokens.
    c�
���t���|��t|t�rt	|�}t|t
�r�j
|�g�_d�_yt|t�r|g�_d�_yt|t�r@t	|�}td�|D��r�fd�|D�}t	|��_d�_y	t	|��_d�_y#t$r|g�_Yd�_ywxYw)Nc3�<K�|]}t|t����y�wr=)r^r#)r4r�s  r6r�z+ParseExpression.__init__.<locals>.<genexpr>>s����@�$�:�d�H�-�@�s�c3�d�K�|]'}t|t�r�j|�n|���)y�wr=)r^r#r�)r4rFr�s  �r6r�z+ParseExpression.__init__.<locals>.<genexpr>?s3�������4>�a��3J�D�,�,�Q�/�PQ�Q��s�-0F)
r�r�r^�_generatorTyper�r#r��exprsrsr�anyr�r��r�r(rr�s`  �r6r�zParseExpression.__init__/s����	����"���e�^�,���K�E��e�X�&��2�2�5�9�:�D�J�""���!��}�
-���D�J�"�����x�
(���K�E��@�%�@�@��"����e��D�J�"���	
%�!�%�[��
�"�����
%�#�W��
�!���
%�s�C'�'D�Dc� �|jddSr=)r(rs r6rzParseExpression.recurseKs���z�z�!�}�rCc�J�|jj|�d|_|Sr=)r(r
r�r�s  r6r
zParseExpression.appendNs!���
�
���%� � ����rCc����t�|�|�|rO|jD�cgc]}|j���c}|_|jD]}|j|��|Scc}w)z�
        Extends ``leave_whitespace`` defined in base class, and also invokes ``leave_whitespace`` on
           all contained expressions.
        )r�rr(r�r�rrFr�s   �r6rz ParseExpression.leave_whitespaceSs\���
	�� ��+��,0�J�J�7�q�!�&�&�(�7�D�J��Z�Z�
.���"�"�9�-�
.����8��A$c����t�|�|�|rO|jD�cgc]}|j���c}|_|jD]}|j|��|Scc}w)z�
        Extends ``ignore_whitespace`` defined in base class, and also invokes ``leave_whitespace`` on
           all contained expressions.
        )r�rr(rr.s   �r6rz!ParseExpression.ignore_whitespace`s\���
	��!�)�,��,0�J�J�7�q�!�&�&�(�7�D�J��Z�Z�
/���#�#�I�.�
/����8r/c�@��t|t�rN||jvr>t�|�|�|j
D] }|j	|jd��"|St�|�|�|j
D] }|j	|jd��"|S�Nr�)r^rr�r�r#r()r�r�rFr�s   �r6r#zParseExpression.ignorels�����e�X�&��D�,�,�,����u�%����3�A��H�H�T�-�-�b�1�2�3���
�G�N�5�!��Z�Z�
/������)�)�"�-�.�
/��rCc�L�t|�j�d|j�d�S�Nz:(r)r�r)r(rs r6r,z$ParseExpression._generateDefaultNamexs$���t�*�%�%�&�b�����A�6�6rCc���|jr|St�|�	�|jD]}|j��t	|j�dk(�re|jd}t||j�r�|js�|j�v|jsj|jdd|jdgz|_d|_
|xj|jzc_|xj|jzc_
|jd}t||j�r�|js�|j�u|jsi|jdd|jddz|_d|_
|xj|jzc_|xj|jzc_
d|��|_|S)NrSrrr�r0)r�r�r�r(rNr^r�r�r�r�r�r�rr�r�)r�rFr�r�s   �r6r�zParseExpression.streamline{ss�������K�
�������	�A�
�L�L�N�	��t�z�z�?�a���J�J�q�M�E��5�$�.�.�1��)�)��%�%�-����"�[�[��^�t�z�z�!�}�o�=��
�$(��!��&�&�%�*>�*>�>�&��"�"�e�&9�&9�9�"��J�J�r�N�E��5�$�.�.�1��)�)��%�%�-����!�Z�Z���_�u�{�{�1�~�=��
�$(��!��&�&�%�*>�*>�>�&��"�"�e�&9�&9�9�"�!�$��(����rCc��tjdtd��|�|ngdd|gz}|jD]}|j	|��|jg�y�NrErSrF)rHr:rIr(rKr@)r�rJ�tmprFs    r6rKzParseExpression.validate�s]���
�
�h���	
�
!.� 9�}�r�1�E���N�����	�A�
�J�J�s�O�	����R� rCc���t�|��}tjt|�}|j
D�cgc]}|j���c}|_|Scc}wr=)r�rr	rr#r()r�r�rFr�s   �r6rzParseExpression.copy�sD����g�l�n���k�k�/�3�/��'+�z�z�2�!�Q�V�V�X�2��	��
��3s�Ac���tjrtj|jvst�|�||�S|jD]~}t|t�s�|js�!tj|jvs�>d|�dt|�j�d|j�d�}tj|d��nt�|�||�S�Nz@warn_ungrouped_named_tokens_in_collection: setting results name � on z expression collides with z on contained expressionrTrF)r8rHrRrr�rr(r^rsr�r�r)rHr:�r�rArrF�warningr�s     �r6rzParseExpression._setResultsName�s�����>�>��E�E��*�*�+��7�*�4�1A�B�B����	�A��1�m�,��M�M��I�I��/�/�0�
-�-1�H�D��d��9L�9L�8M�N&�&'�m�m�%6�6N�P��
�
�
�g�!�4��	�"�w�&�t�-=�>�>rCr�r�r��r(ztyping.Iterable[ParserElement]rrgrErFr�r�r�r�r�r=rD)r)r*r+r,r�rr
rrr#r,r�rKrrrr�r�r�r�s@r6r#r#*s~����
GL�"�3�"�?C�"�	
�"�8��
�
�
�7�'�R	!��?�:'�'8�:J�K�O�'�(:�<M�N�rCr#c�p��eZdZdZGd�de�Z	d
					d�fd�
Zd�fd�Zd
d�Zd�Z	d�Z
d
d	�Z�xZS)r�a
    Requires all given :class:`ParserElement` s to be found in the given order.
    Expressions may be separated by whitespace.
    May be constructed using the ``'+'`` operator.
    May also be constructed using the ``'-'`` operator, which will
    suppress backtracking.

    Example::

        integer = Word(nums)
        name_expr = Word(alphas)[1, ...]

        expr = And([integer("id"), name_expr("name"), integer("age")])
        # more easily written as:
        expr = integer("id") + name_expr("name") + integer("age")
    c�(��eZdZd�fd�Zdd�Z�xZS)�And._ErrorStopc�D��t�|�|i|��|j�yr=)r�r�r)r�r�r;r�s   �r6r�zAnd._ErrorStop.__init__�s!����G��d�-�f�-��!�!�#rCc��y)N�-rYrs r6r,z#And._ErrorStop._generateDefaultName�s��rCrDr��r)r*r+r�r,r�r�s@r6r�rB�s
���	$�	rCr�c���|D�cgc]%}t|t�r|j|�n|��'}}t|vrn|dturt	d��g}t||dd�D]?\}}|tur!|j
t|�d���/|j
|��A||ddt�|�%||�|jr�td�|jD��|_t|jdt�sg|j|jdj|jdj ��|jdj"|_d	|_yd|_d	|_yd	|_d	|_ycc}w)
Nr�z0cannot construct And with sequence ending in ...rr�c3�4K�|]}|j���y�wr=�r�r4rFs  r6r�zAnd.__init__.<locals>.<genexpr>
�����(N�a��)9�)9�(N�r�rr�FT)r^rtr�r�r]r;r
r�r�r�r(r7r�r�rr�r�r�r�)	r��	exprs_argrrFr(r8�cur_expr�	next_exprr�s	        �r6r�zAnd.__init__�s����OX�&
�IJ�:�a��+=�D�$�$�Q�'�1�D�&
��&
�
�u���R�y�H�$�� R�S�S�')�C�'*�5�%���)�'<�
)�#��)��x�'��J�J�0�v�i�0��=�>��J�J�x�(�	
)��E�#�2�J�
�����)��:�:�%(�(N�4�:�:�(N�%N�D�"��d�j�j��m�U�3��)�)��J�J�q�M�,�,�"&�*�*�Q�-�"E�"E�*��'+�j�j��m�&B�&B��#�
!���',��#�!���&*�D�"� ����C&
s�*Fc����|jr�td�|jddD��r�t�}t|jdd�D]�\}}||ur�t	|t
�s�|js�)t	|jdt�s�G|jd|j|dzz|jd<||j|dz<��|jD�cgc]	}||us�|��c}|_t�	|�!�t|j|jdd�D]�\}}t�}	t|�|vr�|jt|��t	|t�r|j|fd���^|j�}t!t#|�d�}|���t%j&t(|�}��t+d�|jD��|_|Scc}w)Nc3�K�|]A}t|t�xr+|jxrt|jdt����Cy�w�r�N)r^r#r(r�rJs  r6r�z!And.streamline.<locals>.<genexpr>sI����
��
�q�/�*�
6����
6��1�7�7�2�;��5�
6�
�s�AA	r�rc�0�t|dt||��S)N�
parent_anchor)�setattrr�)r�r�r��cur_s    r6r�z And.streamline.<locals>.<lambda>>s��'� �/�3�q�!�9�3�rCc3�4K�|]}|j���y�wr=rIrJs  r6r�z!And.streamline.<locals>.<genexpr>Is����$J�!�Q�%5�%5�$J�r�)r(r)rr:r^r#r�r�r�r;r�r\r�
IndentedBlockr>rr{rr	rrsr7r�)
r��deleted_expr_markerrdrF�prevrr�subs�
next_firstr�s
         �r6r�zAnd.streamlines�����:�:�#�
��Z�Z���_�	
�
�#*�)��!�$�*�*�S�b�/�2�	
<���1��+�+���q�/�2����"�1�7�7�2�;��=�"#�'�'�"�+��
�
�1�q�5�0A�"A�A�G�G�B�K�(;�D�J�J�q�1�u�%�	
<�&*�Z�Z�P��1�<O�3O�!�P�D�J�
����
�T�Z�Z����A�B��8�	=�I�D�#��5�D���c�7�d�?������C��!��c�=�1��)�)�-0���
��{�{�}��!�$�t�*�d�3�
��%���k�k�-��<���		=�*"%�$J�t�z�z�$J�!J������;Qs�'	G3�1G3c���|jdj|||d��\}}d}|jddD]U}t|�tjurd}�!|r	|j|||�\}}n|j|||�\}}||z
}�W||fS#t
$r�t$r!}d|_t
j|��d}~wt$r"t|t|�|j|��wxYw)NrFr�rT)r(r-r�r�r��ParseSyntaxExceptionr�r��_from_exceptionr�rNr�)	r�r�r�r'�
resultlist�	errorStoprF�
exprtokensr�s	         r6rTz
And.parseImplLs���*�*�Q�-�.�.��c�:�E�/�
���Z��	����A�B��	%�A��A�w�#�.�.�(� �	���
�&'�h�h�x��j�&I�O�C��#$�(�(�8�S�*�"E���Z��*�$�J�'	%�(�J����,���)�C�'+�B�$�.�>�>�r�B�B��!��.� �#�h�-����d����s�B�C/�%C�.C/c��t|t�r|j|�}t|t�stS|j|�Sr=�r^r#r�rsr�r
r�s  r6�__iadd__zAnd.__iadd__i�;���e�X�&��,�,�U�3�E��%��/�!�!��{�{�5�!�!rCc�v�|dd|gz}|jD]!}|j|�|jr�!yyr=)r(r@rrAs    r6r@zAnd._checkRecursionps@��*�1�-���6�����	�A�
���o�.��#�#��	rCc���djd�|jD��}t|�dkDrB|ddt|�dz
�dk(r+|dd}t|�dkDr|ddt|�dz
�dk(r�+d|�d�S)	Nrc3�2K�|]}t|����y�wr=r9rJs  r6r�z+And._generateDefaultName.<locals>.<genexpr>xs����4�A��Q��4�r4rr�{}r�rKrL)r�r(rN�r��inners  r6r,zAnd._generateDefaultNamews������4����4�4���%�j�1�n��q�':�C��J��N�':�!;�t�!C��!�B�K�E��%�j�1�n��q�':�C��J��N�':�!;�t�!C��E�7�"�~�rCr�)rLz*typing.Iterable[Union[ParserElement, str]]rrgrErFr�r�)
r)r*r+r,r�r�r�r�rTrdr@r,r�r�s@r6r�r��sU����"�U���'!�=�'!��'!�
�	'!�R0�d�:"��rCr�c�d��eZdZdZ	d					d	�fd�
Zd
�fd�Zddd�Zd�Zd
d�Zdd
�fd�
Z	�xZ
S)r�a�Requires that at least one :class:`ParserElement` is found. If
    two expressions match, the expression that matches the longest
    string will be used. May be constructed using the ``'^'``
    operator.

    Example::

        # construct Or using '^' operator

        number = Word(nums) ^ Combine(Word(nums) + '.' + Word(nums))
        print(number.search_string("123 3.1416 789"))

    prints::

        [['123'], ['3.1416'], ['789']]
    c����t�|�||�|jrCtd�|jD��|_td�|jD��|_yd|_y)Nc3�4K�|]}|j���y�wr=rIrJs  r6r�zOr.__init__.<locals>.<genexpr>�rKr�c3�4K�|]}|j���y�wr=rrJs  r6r�zOr.__init__.<locals>.<genexpr>������%K�1�a�&6�&6�%K�r�T�r�r�r(r)r�r7r�r*s   �r6r�zOr.__init__��Q���	�����)��:�:�%(�(N�4�:�:�(N�%N�D�"�"%�%K��
�
�%K�"K�D��%)�D�"rCc���t�|��|jretd�|jD��|_td�|jD��|_t
d�|jD��|_|Sd|_|S)Nc3�4K�|]}|j���y�wr=rIrJs  r6r�z Or.streamline.<locals>.<genexpr>�rKr�c3�4K�|]}|j���y�wr=�r�rJs  r6r�z Or.streamline.<locals>.<genexpr>������!C�1�!�,�,�!C�r�c3�ZK�|]#}|jxrt|t����%y�wr=�r�r^r�rJs  r6r�z Or.streamline.<locals>.<genexpr>��-����&�BC�� � �=��A�u�)=�%=�=�&���)+F)r�r�r(r)r�r�r7r�r�s �r6r�z
Or.streamline�su���
�����:�:�%(�(N�4�:�:�(N�%N�D�"�!�!C��
�
�!C�C�D�O�"%�&�GK�z�z�&�#�D��
��$�D�O��rCc�
�d}d}g}g}td�|jD��r|j||�}|jD]*}	|j||d��}	|j	|	|f��,|r�|jtd�d��|s|dd}|j|||�Sd}
|D]@\}}||
dkr|
cS	|j|||�\}	}|	|k\r|	|fcS|	|
dkDs�=|	|f}
�B|
dk7r|
S|rZt|�dkDrE|jd	��
�|dj|djk(r|jd��
�|d}|�|�.|j||�}||k(r|jxsd|_|�t||d
|��#t
$r.}
d|
_||
_|j	|
�d}d}Yd}
~
���d}
~
wt$r1}|s$d|_|j|kDr|}|j}Yd}~���d}~wt$r>t|�|kDr,t|t|�|j|�}t|�}Y��wxYw#t$r/}d|_|j|kDr|}|j}Yd}~���d}~wwxYw)Nr�c3�4K�|]}|j���y�wr=)r�rJs  r6r�zOr.parseImpl.<locals>.<genexpr>�s����2�!�q�~�~�2�r�T�rhr)r�reverserrQc��|jSr=�r��rFs r6r�zOr.parseImpl.<locals>.<lambda>����1�5�5�&�rC�rc�Z�|jtt|j��fSr=�r�rNrt�parser_elementr�s r6r�zOr.parseImpl.<locals>.<lambda>��$�����v��C��@P�@P�<Q�8R�7R�.S�rCrf� no defined alternatives to match)r7r(rQrkr
r�r�r�r�r�r�rNr��sortrr-r�)r�r�r�r'�	maxExcLoc�maxExceptionr��fatalsrF�loc2�pferd�	best_expr�longest�loc1�expr1r��	max_fatal�parse_start_locs                   r6rTzOr.parseImpl�s����	���35��,.���2�t�z�z�2�2��-�-��#�.�C����	*�A�
*��{�{�8�S�d�{�C��*����a�y�)�/	*�2�
�L�L�Z��]�D�L�9��$�A�J�q�M�	� �'�'��#�z�B�B�AI�G�&�
-���e��7�1�:�%�"�N�-�!&���h��Z�!H�J�D�$��t�|�#�T�z�)����
�*�"&��*��#
-�&�*�$�����6�{�Q����� 0��1��!�9�=�=�F�1�I�M�M�1��K�K�$S�K�T��q�	�I��O��#�#�m�m�H�c�:�O��O�+�#'�;�;�#4�"�� ����X�s�,N�PT�U�U��Q'�
�$(��!�%&��"��
�
�c�"�#���	��!�
,��(,�C�%��w�w��*�'*��$'�G�G�	����
.��x�=�9�,�#1� �#�h�-����4�$�L�!$�H�
�I��
.��:&�,�(,�C�%��w�w��*�'*��$'�G�G�	���	,�sC�F�I
�	I�#G�I�&G=�=AI�I�
	J�$I=�=Jc��t|t�r|j|�}t|t�stS|j|�Sr=rcr�s  r6�__ixor__zOr.__ixor__�rerCc�N�ddjd�|jD���d�S)NrKz ^ c3�2K�|]}t|����y�wr=r9rJs  r6r�z*Or._generateDefaultName.<locals>.<genexpr>�����:�!�s�1�v�:�r4rL�r�r(rs r6r,zOr._generateDefaultName�%���E�J�J�:�t�z�z�:�:�;�2�>�>rCc���tjrktj|jvrOt	d�|j
D��r3d|�dt
|�j�d�}tj|d��t�|�-||�S)Nc3�xK�|]2}t|t�xrtj|jv���4y�wr=�r^r�rRrGrrJs  r6r�z%Or._setResultsName.<locals>.<genexpr>�B�������1�c�"�,��I�I��+�+�,�,����8:�@warn_multiple_tokens_in_named_alternation: setting results name r<�� expression will return a list of all parsed tokens in an And alternative, in prior versions only the first token was returned; enclose contained argument in GrouprTrF�r8rGrRrr)r(r�r)rHr:r�r�r�rArr>r�s    �r6rzOr._setResultsName�����>�>��E�E��*�*�+������	��-�-1�H�D��d��9L�9L�8M�N3�3���
�
�g�!�4��w�&�t�-=�>�>rCr�r?r�r�r�r�)r)r*r+r,r�r�rTr�r,rr�r�s@r6r�r�sM����$GL�*�3�*�?C�*�	
�*�
�RV�h"�?�?�?rCr�c�d��eZdZdZ	d					d	�fd�
Zd
�fd�Zddd�Zd�Zd
d�Zdd
�fd�
Z	�xZ
S)r�a�Requires that at least one :class:`ParserElement` is found. If
    more than one expression matches, the first one listed is the one that will
    match. May be constructed using the ``'|'`` operator.

    Example::

        # construct MatchFirst using '|' operator

        # watch the order of expressions to match
        number = Word(nums) | Combine(Word(nums) + '.' + Word(nums))
        print(number.search_string("123 3.1416 789")) #  Fail! -> [['123'], ['3'], ['1416'], ['789']]

        # put more selective expression first
        number = Combine(Word(nums) + '.' + Word(nums)) | Word(nums)
        print(number.search_string("123 3.1416 789")) #  Better -> [['123'], ['3.1416'], ['789']]
    c����t�|�||�|jrCtd�|jD��|_td�|jD��|_yd|_y)Nc3�4K�|]}|j���y�wr=rIrJs  r6r�z&MatchFirst.__init__.<locals>.<genexpr>4rKr�c3�4K�|]}|j���y�wr=rrJs  r6r�z&MatchFirst.__init__.<locals>.<genexpr>5rpr�Trqr*s   �r6r�zMatchFirst.__init__/rrrCc�>��|jr|St�|�	�|jret	d�|jD��|_t	d�|jD��|_td�|jD��|_|Sd|_d|_|S)Nc3�4K�|]}|j���y�wr=rvrJs  r6r�z(MatchFirst.streamline.<locals>.<genexpr>?rwr�c3�4K�|]}|j���y�wr=rIrJs  r6r�z(MatchFirst.streamline.<locals>.<genexpr>@rKr�c3�ZK�|]#}|jxrt|t����%y�wr=ryrJs  r6r�z(MatchFirst.streamline.<locals>.<genexpr>Arzr{FT)	r�r�r�r(r)r�r�r7r�r�s �r6r�zMatchFirst.streamline9s��������K�
�����:�:�!�!C��
�
�!C�C�D�O�%(�(N�4�:�:�(N�%N�D�"�"%�&�GK�z�z�&�#�D����$�D�O�%)�D�"��rCc��d}d}|jD]}	|j|||�cS|�.|j||�}	||	k(r|jxsd|_|�t||d|��#t$r}d|_||_�d}~wt
$r'}|j|kDr|}|j}Yd}~��d}~wt$r=t|�|kDr,t|t|�|j|�}t|�}Y��wxYw)Nr�rfr�)r(r-r�r�r�r�r�r�rNr�rQr�)
r�r�r�r'r�r�rFr�rdr�s
          r6rTzMatchFirst.parseImplIs���	������	.�A�
.��x�x��#�z�:�:�	.�$�#�#�m�m�H�c�:�O��O�+�#'�;�;�#4�"�� ����X�s�,N�PT�U�U��/'�
�$(��!�%&��"���!�
(��7�7�Y�&�#&�L� #���I����
.��x�=�9�,�#1� �#�h�-����4�$�L�!$�H�
�I��
.�s*�A)�)	C8�2B�C8�
B/�/AC8�7C8c��t|t�r|j|�}t|t�stS|j|�Sr=rcr�s  r6�__ior__zMatchFirst.__ior__irerCc�N�ddjd�|jD���d�S)NrKz | c3�2K�|]}t|����y�wr=r9rJs  r6r�z2MatchFirst._generateDefaultName.<locals>.<genexpr>qr�r4rLr�rs r6r,zMatchFirst._generateDefaultNamepr�rCc���tjrktj|jvrOt	d�|j
D��r3d|�dt
|�j�d�}tj|d��t�|�-||�S)Nc3�xK�|]2}t|t�xrtj|jv���4y�wr=r�rJs  r6r�z-MatchFirst._setResultsName.<locals>.<genexpr>yr�r�r�r<r�rTrFr�r�s    �r6rzMatchFirst._setResultsNamesr�rCr�r?r�r�r�r�)r)r*r+r,r�r�rTr�r,rr�r�s@r6r�r�sL����$GL�*�3�*�?C�*�	
�*�� V�@"�?�?�?rCr�c�V��eZdZdZ	d					d�fd�
Zd�Zd	�fd�Zdd
d�Zdd�Z�xZ	S)r�ajRequires all given :class:`ParserElement` s to be found, but in
    any order. Expressions may be separated by whitespace.

    May be constructed using the ``'&'`` operator.

    Example::

        color = one_of("RED ORANGE YELLOW GREEN BLUE PURPLE BLACK WHITE BROWN")
        shape_type = one_of("SQUARE CIRCLE TRIANGLE STAR HEXAGON OCTAGON")
        integer = Word(nums)
        shape_attr = "shape:" + shape_type("shape")
        posn_attr = "posn:" + Group(integer("x") + ',' + integer("y"))("posn")
        color_attr = "color:" + color("color")
        size_attr = "size:" + integer("size")

        # use Each (using operator '&') to accept attributes in any order
        # (shape and posn are required, color and size are optional)
        shape_spec = shape_attr & posn_attr & Opt(color_attr) & Opt(size_attr)

        shape_spec.run_tests('''
            shape: SQUARE color: BLACK posn: 100, 120
            shape: CIRCLE size: 50 color: BLUE posn: 50,80
            color:GREEN size:20 shape:TRIANGLE posn:20,40
            '''
            )

    prints::

        shape: SQUARE color: BLACK posn: 100, 120
        ['shape:', 'SQUARE', 'color:', 'BLACK', 'posn:', ['100', ',', '120']]
        - color: BLACK
        - posn: ['100', ',', '120']
          - x: 100
          - y: 120
        - shape: SQUARE


        shape: CIRCLE size: 50 color: BLUE posn: 50,80
        ['shape:', 'CIRCLE', 'size:', '50', 'color:', 'BLUE', 'posn:', ['50', ',', '80']]
        - color: BLUE
        - posn: ['50', ',', '80']
          - x: 50
          - y: 80
        - shape: CIRCLE
        - size: 50


        color: GREEN size: 20 shape: TRIANGLE posn: 20,40
        ['color:', 'GREEN', 'size:', '20', 'shape:', 'TRIANGLE', 'posn:', ['20', ',', '40']]
        - color: GREEN
        - posn: ['20', ',', '40']
          - x: 20
          - y: 40
        - shape: TRIANGLE
        - size: 20
    c���t�|�||�|jr"td�|jD��|_nd|_d|_d|_d|_y)Nc3�4K�|]}|j���y�wr=rIrJs  r6r�z Each.__init__.<locals>.<genexpr>�rKr�T)r�r�r(r7r�r��initExprGroupsr�r*s   �r6r�z
Each.__init__�sQ���	�����)��:�:�%(�(N�4�:�:�(N�%N�D�"�%)�D�"�"���"�����rCc��t|t�r|j|�}t|t�stS|j|�Sr=rcr�s  r6�__iand__z
Each.__iand__�rerCc���t�|��|jr#td�|jD��|_|Sd|_|S)Nc3�4K�|]}|j���y�wr=rIrJs  r6r�z"Each.streamline.<locals>.<genexpr>�rKr�T)r�r�r(r7r�r�s �r6r�zEach.streamline�sB���
�����:�:�%(�(N�4�:�:�(N�%N�D�"���&*�D�"��rCc	�t�|j�r�td�|jD��|_|jD�cgc]}t	|t
�s�|j��!}}|jD�cgc]+}|jrt	|t
ttf�s|��-}}||z|_
|jD�cgc]9}t	|t�r'|jj|jd����;c}|_|jD�cgc]9}t	|t�r'|jj|jd����;c}|_|jD�cgc] }t	|t
ttf�r�|��"c}|_|xj"|j z
c_d|_|}|j"dd}|jdd}	|jdd}
g}d}g}
g}|r�||	z|
z}|
j%�|j%�|D]w}	|j'||d��}|j)|jj+t-|�|��||vr|j/|��b||	vs�g|	j/|��yt9|
�t9|�k(rd}|r��|rZt9|�dkDrE|j;d���|d	j<|dj<k(r|j;d
���|d	}|�|r9dj?|D�cgc]
}tA|���c}�}t7||d|�d
���||jD�cgc]$}t	|t
�s�|j|	vs�#|��&c}z
}tCg�}|D]}|jE|||�\}}||z
}�||fScc}wcc}wcc}wcc}wcc}w#t0$r;}d|_||_|j)|�|
j)|�Yd}~���d}~wt6$r|
j)|�Y��wxYwcc}wcc}w)Nc3�lK�|],}t|t�s�t|j�|f���.y�wr=)r^r�r\r�rJs  r6r�z!Each.parseImpl.<locals>.<genexpr>�s*���� �$%�z�!�S�7I��A�F�F��Q�� �s�4�4T)rFr~rc��|jSr=r�r�s r6r�z Each.parseImpl.<locals>.<lambda>r�rCr�rc�Z�|jtt|j��fSr=r�r�s r6r�z Each.parseImpl.<locals>.<lambda>!r�rCrlz'Missing one or more required elements (r)#r�r�r(�opt1mapr^r�r�rrwr��	optionalsr
r r��multioptionalsr��
multirequired�requiredr6rkr
r8r\�remover�r�r�r�rNr�r�r�rtr r-)r�r�r�r'rF�opt1�opt2�tmpLoc�tmpReqd�tmpOpt�multis�
matchOrder�keepMatching�failedr��tmpExprsr�r��missing�
total_resultsrAs                     r6rTzEach.parseImpl�s������� �)-��� ��D�L�%)�J�J�E�q�*�Q��2D�A�F�F�E�D�E�������#�#�J�q�3��z�:R�,S���D��
"�D�[�D�N����#���a��0����'�'��
�
��'�M�#�D�����"���a��+����'�'��
�
��'�M�"�D�� �:�:���Z��C��Y�;W�-X���D�M�
�M�M�T�/�/�/�M�"'�D�����-�-��"������"���$�$�Q�'��*,�
���&(��,.�����'�&�0�H��L�L�N��L�L�N��
)��)��[�[��6�t�[�L�F��%�%�d�l�l�&6�&6�r�!�u�a�&@�A��G�|����q�)��f���
�
�a�(�
)� �6�{�c�(�m�+�$��+�0��6�{�Q����� 0��1��!�9�=�=�F�1�I�M�M�1��K�K�$S�K�T��q�	�I��O���i�i�� 9�A��Q�� 9�:�G� ���9�'��!�D��
�	�$�*�*�X�Q�
�1�c�0B�q�v�v�QW�GW�q�X�X�
�$�R�(�
��	%�A��8�8�H�c�:�>�L�C���W�$�M�	%��M�!�!��aF����#��
"��
��,+�%�(,�C�%�)*�C�&��M�M�#�&��M�M�!�$�$��%�%��M�M�!�$�%��*!:��Ys_�N4�N4�10N9�;>N>�>O�# O�O�O
�P0�P5�+P5�:P5�
	P-�0P�P-�,P-c�N�ddjd�|jD���d�S)NrKz & c3�2K�|]}t|����y�wr=r9rJs  r6r�z,Each._generateDefaultName.<locals>.<genexpr>8r�r4rLr�rs r6r,zEach._generateDefaultName7r�rCr�r?r�r�r�)
r)r*r+r,r�r�r�rTr,r�r�s@r6r�r��sC���7�tGK�
�3�
�?C�
�	
�
�"��U"�n?rCr�c���eZdZdZdd�fd�
Zdd�Zdd�Zdd�fd�
Zdd�fd�
Zd�fd�Z	d�fd�Z
d	�Zddd
�Zdd�Z
ede�Zed
e�Z�xZS)�ParseElementEnhancezfAbstract subclass of :class:`ParserElement`, for combining and
    post-processing parsed tokens.
    c����t�|�|�t|t�r�t	j
t|�}t|jt�r|j|�}nEtt|�|j�rt|�}n|jt|��}t	j
t|�}||_
|��|j|_|j|_|j#|j$|j&��|j(|_|j*|_|j,|_|j.j1|j.�yy)Nr�)r�r�r^r#r	rrt�
issubclassr�r�r�rmrsr�r�rr�rr�r�r�r�r�r�r)r�r�r�expr_strr�s    �r6r�zParseElementEnhance.__init__@s ���
����"��d�H�%��{�{�3��-�H��$�2�2�E�:��/�/��9���D��J��(@�(@�A��x�(���/�/���0A�B���{�{�=�$�/����	���!%�!3�!3�D��%)�%8�%8�D�"��%�%����t�/I�/I�
&�
�#'�"5�"5�D��"�o�o�D�O� $� 1� 1�D�����#�#�D�$4�$4�5�rCc�8�|j�
|jgSgSr=�r�rs r6rzParseElementEnhance.recurseWs��"�i�i�3��	�	�{�;��;rCc��|j�t||d|��	|jj|||d��S#t$r�t$r~}|j
xs||_|jxs||_|jxs||_t|t�s)|j�|jr|j|_�d}~wwxYw)NzNo expression definedFr�)
r�r�r-r]r��pstrr�r�r^�Forwardr�r�r�)r�r�r�r'�pbes     r6rTzParseElementEnhance.parseImplZs����9�9�� ��3�0G��N�N�	��9�9�#�#�H�c�:�E�#�R�R��#�	��!�	��x�x�+�8�C�H��g�g�n��C�G�!$�!3�!3�!;�t�C���d�G�,����1L��;�;�"�k�k�C�G���	�s�;�C�
A9C�Cc���t�|�|�|rF|j�:|jj�|_|jj|�|Sr=)r�rr�r�r�rr�s  �r6rz$ParseElementEnhance.leave_whitespaceksF���
�� ��+���y�y�$� �I�I�N�N�,��	��	�	�*�*�9�5��rCc���t�|�|�|rF|j�:|jj�|_|jj|�|Sr=)r�rr�rr�s  �r6rz%ParseElementEnhance.ignore_whitespacetsF���
��!�)�,���y�y�$� �I�I�N�N�,��	��	�	�+�+�I�6��rCc����t|t�r||jvrCt�|�|�|j
�(|j
j	|jd�|Sr2)r^rr�r�r#r��r�r�r�s  �r6r#zParseElementEnhance.ignore}sR����%��*�e�4�;K�;K�.K��G�N�5�!��y�y�$��	�	� � ��!1�!1�"�!5�6��rCc�p��t�|��|j�|jj�|Sr=)r�r�r�r�s �r6r�zParseElementEnhance.streamline�s-���
�����9�9� ��I�I� � �"��rCc��||vrt||gz��|dd|gz}|j�|jj|�yyr=)�RecursiveGrammarExceptionr�r@)r�rBrCs   r6r@z#ParseElementEnhance._checkRecursion�sP���#�#�+�,<��v�,E�F�F�*�1�-���6���9�9� ��I�I�%�%�o�6�!rCc���tjdtd��|�g}|dd|gz}|j�|jj	|�|jg�yr7�rHr:rIr�rKr@�r�rJr8s   r6rKzParseElementEnhance.validate�s_���
�
�h���	
�
� ��M��A��$��'���9�9� ��I�I���s�#����R� rCc�L�t|�j�d|j�d�Sr4)r�r)r�rs r6r,z(ParseElementEnhance._generateDefaultName�s$���t�*�%�%�&�b�����1�5�5rCr�r�r��r��Union[ParserElement, str]rrgrErFr�r�r�r�r=rDr�)r)r*r+r,r�rrTrrr#r�r@rKr,rr�r�r�r�s@r6r�r�;sY����6�.<��"����7�!�6�
'�'8�:J�K�O�'�(:�<M�N�rCr�c�p��eZdZdZGd�de�ZGd�de�Zddd�							d�fd	�Zdd
d
�Z�xZ	S)rWz�
    Expression to match one or more expressions at a given indentation level.
    Useful for parsing text where structure is implied by indentation (like Python source code).
    c� ��eZdZd�fd�Z�xZS)�IndentedBlock._Indentc�`���t�|��d���|_|j�fd��y)Nzexpected indent at column c�"��t||��k(Sr=�r��r�r�r��ref_cols   �r6r�z0IndentedBlock._Indent.__init__.<locals>.<lambda>�s���s�1�a�y�G�/C�rC�r�r�r�r@�r�r�r�s `�r6r�zIndentedBlock._Indent.__init__�s+����G���6�w�i�@�D�K����C�DrC�r�r�rErFr�r�s@r6�_Indentr��s���	E�	ErCr�c� ��eZdZd�fd�Z�xZS)�IndentedBlock._IndentGreaterc�`���t�|��d���|_|j�fd��y)Nz'expected indent at column greater than c�"��t||��kDSr=r�r�s   �r6r�z7IndentedBlock._IndentGreater.__init__.<locals>.<lambda>�s���s�1�a�y�7�/B�rCr�r�s `�r6r�z%IndentedBlock._IndentGreater.__init__�s+����G���C�G�9�M�D�K����B�CrCr�r�r�s@r6�_IndentGreaterr��s���	D�	DrCr�FT�r�groupedc�R��t�|�|d��||_||_d|_y)NTr�r)r�r��
_recursive�_groupedrS)r�r�rrr�s    �r6r�zIndentedBlock.__init__�s/���	������-�$�����
���rCc�$�t�j||�}|jj|||��t	||�}|j|�}t�|z|jz}|jrp|j|�}t|j|j|j��}	|	j|j�||	_|t||	z�z
}|jdtt!|��ddj#��d|���t%|�}
|j|j�t'�z}|jrt(}nd�}||
�t+|�zj-|||�S)Nrjrzinner ����@c��|Sr=rYr�s r6r�z)IndentedBlock.parseImpl.<locals>.<lambda>�s��4�rC)r�rQr�rkr�r�rr�rWrr�r�rSr�r1�hexr\rr�r��Group�OptionalrT)
r�r�r�r'�
anchor_loc�
indent_col�peer_detect_expr�
inner_expr�
sub_indent�nested_block�block�trailing_undentr�s
             r6rTzIndentedBlock.parseImpl�s[���W�%�%�h��4�
�	
�	�	���H�j�Z��H���X�.�
��<�<�
�3���W�/�/�$�)�)�;�
��?�?��,�,�Z�8�J�(��	�	�T�_�_�d�m�m��L�
�"�"�4�:�:�.�)3�L�&��#�j�<�7�8�8�J����f�S��J��%8���%=�%C�%C�%E�$F�a�
�|�T�U��*�%���,�,�t�'9�'9�:�Y�[�H���=�=��G�'�G�����/�!:�:�E�E��j�*�
�	
rC)r�rsrrgrrgrErFr�r�)
r)r*r+r,r�r�r�r�rTr�r�s@r6rWrW�sZ����
E�%�E�D��D�9>�t��!��15��HL��	
��!
�!
rCrWc�2��eZdZdZd�fd�Zdd�fd�
Z�xZS)�
AtStringStartz�Matches if expression matches at the beginning of the parse
    string::

        AtStringStart(Word(nums)).parse_string("123")
        # prints ["123"]

        AtStringStart(Word(nums)).parse_string("    123")
        # raises ParseException
    c�2��t�|�|�d|_y�NF�r�r�r��r�r�r�s  �r6r�zAtStringStart.__init__�����
�����!��rCc�J��|dk7r
t||d��t�|�	|||�S)Nrznot found at string start)r�r�rT�r�r�r�r'r�s    �r6rTzAtStringStart.parseImpl�s.����!�8� ��3�0K�L�L��w� ��3�
�;�;rC�r�r�rErFr�r�r�r�s@r6rr�s����"�<�<rCrc�2��eZdZdZd�fd�Zdd�fd�
Z�xZS)�AtLineStarta�Matches if an expression matches at the beginning of a line within
    the parse string

    Example::

        test = '''\
        AAA this line
        AAA and this line
          AAA but not this one
        B AAA and definitely not this one
        '''

        for t in (AtLineStart('AAA') + rest_of_line).search_string(test):
            print(t)

    prints::

        ['AAA', ' this line']
        ['AAA', ' and this line']

    c�2��t�|�|�d|_yrrrs  �r6r�zAtLineStart.__init__rrCc�^��t||�dk7r
t||d��t�|�
|||�S)Nrznot found at line start)r�r�r�rTrs    �r6rTzAtLineStart.parseImpls6����s�H���"� ��3�0I�J�J��w� ��3�
�;�;rCrr�r�r�r�s@r6rr�s����,"�<�<rCrc�.��eZdZdZd�fd�Zddd�Z�xZS)�
FollowedByacLookahead matching of the given parse expression.
    ``FollowedBy`` does *not* advance the parsing position within
    the input string, it only verifies that the specified parse
    expression matches at the current position.  ``FollowedBy``
    always returns a null token list. If any results names are defined
    in the lookahead expression, those *will* be returned for access by
    name.

    Example::

        # use FollowedBy to match a label only if it is followed by a ':'
        data_word = Word(alphas)
        label = data_word + FollowedBy(':')
        attr_expr = Group(label + Suppress(':') + OneOrMore(data_word, stop_on=label).set_parse_action(' '.join))

        attr_expr[1, ...].parse_string("shape: SQUARE color: BLACK posn: upper left").pprint()

    prints::

        [['shape', 'SQUARE'], ['color', 'BLACK'], ['posn', 'upper left']]
    c�2��t�|�|�d|_yr<�r�r�r�rs  �r6r�zFollowedBy.__init__6s���
�����!%��rCc�V�|jj|||��\}}|dd�=||fS�Nrj)r�r-)r�r�r�r'r(r�s      r6rTzFollowedBy.parseImpl:s3�����!�!�(�C�J�!�G���3���F��C�x�rCrr�r�r�r�s@r6r#r#s����,&��rCr#c�0��eZdZdZdd�fd�
Zddd�Z�xZS)�
PrecededBya�Lookbehind matching of the given parse expression.
    ``PrecededBy`` does not advance the parsing position within the
    input string, it only verifies that the specified parse expression
    matches prior to the current position.  ``PrecededBy`` always
    returns a null token list, but if a results name is defined on the
    given expression, it is returned.

    Parameters:

    - ``expr`` - expression that must match prior to the current parse
      location
    - ``retreat`` - (default= ``None``) - (int) maximum number of characters
      to lookbehind prior to the current parse location

    If the lookbehind expression is a string, :class:`Literal`,
    :class:`Keyword`, or a :class:`Word` or :class:`CharsNotIn`
    with a specified exact or maximum length, then the retreat
    parameter is not required. Otherwise, retreat must be specified to
    give a maximum number of characters to look back from
    the current parse position for a lookbehind match.

    Example::

        # VB-style variable names with type prefixes
        int_var = PrecededBy("#") + pyparsing_common.identifier
        str_var = PrecededBy("$") + pyparsing_common.identifier

    c�v��t�|�|�|j�j�|_d|_d|_d|_t|t�r-tjt|�}t|�}d|_n�t|ttf�r|j}d|_nVt|t t"f�r'|j$t&k7r|j$}d|_nt|t(�r	d}d|_||_d|��|_d|_|j0j3d��y)NTFrznot preceded by c�8�|jtdd��Sr=)�__delitem__r�r�r�r�s   r6r�z%PrecededBy.__init__.<locals>.<lambda>ws���
�
�e�D�$�>O�0P�rC)r�r�r�rr�r�r^r^r#r	rrtrNrmrrrCr�rSr�r��retreatr�r�r�r
)r�r�r.r�s   �r6r�zPrecededBy.__init__as����
������I�I�K�0�0�2��	�!%���"�����
��d�H�%��;�;�s�D�)�D��$�i�G��D�J�
��w��0�
1��m�m�G��D�J�
��t�Z�0�
1�d�k�k�X�6M��k�k�G��D�J�
��m�
,��G��D�J����(���/���#�������� P�QrCc�8�|jrY||jkrt|||j|��||jz
}|jj||�\}}||fS|jt
�z}|td||jz
�|}t|||j|�}	tdt||jdz�dz�D](}
	|j|t|�|
z
�\}}||fS|	�#t$r}|}	Yd}~�=d}~wwxYwr)r^r.r�r�r�r-r�r]r�r�rNr�)r�r�r�r'r�r(r��	test_expr�instring_slice�	last_expr�offsetr�s            r6rTzPrecededBy.parseImplys���:�:��T�\�\�!�$�X�s�D�K�K��F�F��$�,�,�&�E��Y�Y�%�%�h��6�F�A�s���8�O��I�I�	��+�	�!�#�a��t�|�|�);�"<�s�C��(6�x��d�k�k�SW�(X�	��A�s�3����q�(8�9�A�=�>�		�F�
�"�)�)�.�#�n�:M�PV�:V�W���3���C�x��		��O��&�
 ��	��
 �s�!D�	D�
D�Dr�)r�r�r.r�rErF)rTr�r�r�s@r6r)r)Cs����:R�0�rCr)c��eZdZdZddd�Zy)�Locateda�
    Decorates a returned token with its starting and ending
    locations in the input string.

    This helper adds the following results names:

    - ``locn_start`` - location where matched expression begins
    - ``locn_end`` - location where matched expression ends
    - ``value`` - the actual parsed results

    Be careful if the input text contains ``<TAB>`` characters, you
    may want to call :class:`ParserElement.parse_with_tabs`

    Example::

        wd = Word(alphas)
        for match in Located(wd).search_string("ljsdf123lksdjjf123lkkjj1222"):
            print(match)

    prints::

        [0, ['ljsdf'], 5]
        [8, ['lksdjjf'], 15]
        [18, ['lkkjj'], 23]

    c��|}|jj|||d��\}}t|||g�}||d<||d<||d<|jr||gfS||fS)NFr��
locn_startr
�locn_end)r�r-r r�)r�r�r�r'r�rcres       r6rTzLocated.parseImpl�sx�����i�i�&�&�x��
�QV�&�W���V�!�5�&�#�"6�7�
�#(�
�<� �$�
�7��!$�
�:��������$�$��
�?�"rCNr�r�)r)r*r+r,rTrYrCr6r5r5�s���6#rCr5c�6��eZdZdZd�fd�Zddd�Zdd�Z�xZS)	ra�
    Lookahead to disallow matching with the given parse expression.
    ``NotAny`` does *not* advance the parsing position within the
    input string, it only verifies that the specified parse expression
    does *not* match at the current position.  Also, ``NotAny`` does
    *not* skip over leading whitespace. ``NotAny`` always returns
    a null token list.  May be constructed using the ``'~'`` operator.

    Example::

        AND, OR, NOT = map(CaselessKeyword, "AND OR NOT".split())

        # take care not to mistake keywords for identifiers
        ident = ~(AND | OR | NOT) + Word(alphas)
        boolean_term = Opt(NOT) + ident

        # very crude boolean expression - to support parenthesis groups and
        # operation hierarchy, use infix_notation
        boolean_expr = boolean_term + ((AND | OR) + boolean_term)[...]

        # integers that are followed by "." are actually floats
        integer = Word(nums) + ~Char(".")
    c�h��t�|�|�d|_d|_d|j��|_y)NFTzFound unwanted token, )r�r�r�r�r�r�rs  �r6r�zNotAny.__init__�s4���
�����$���!%���.�t�y�y�k�:��rCc�v�|jj|||��rt|||j|��|gfSr')r�rmr�r�rSs    r6rTzNotAny.parseImpl�s9���9�9�#�#�H�c�j�#�I� ��3����T�B�B��B�w�rCc�"�d|j�d�S)Nz~{rLr�rs r6r,zNotAny._generateDefaultName�s���T�Y�Y�K�r�"�"rCrr�r�r��r)r*r+r,r�rTr,r�r�s@r6rr�s����0;��
#rCrc�X��eZdZ	ddd�							d�fd�Zd	d�Zd
dd�Zdd	�fd�
Z�xZS)
r
N�rc���t�|�|�|xs|}d|_|}t|t�r|j|�}|j
|�yr<)r�r�r�r^r#r�r)r�r�rr�enderr�s     �r6r�z_MultipleMatch.__init__�sN���	������"�7��������e�X�&��,�,�U�3�E����E�rCc�n�t|t�r|j|�}|�
||_|Sd|_|Sr=)r^r#r��	not_ender)r�rAs  r6rz_MultipleMatch.stopOn�s=���e�X�&��,�,�U�3�E�#(�#4�%������;?����rCc�j�|jj}|j}d}|j�|jj}d}|r	||�||||�\}}	|j
}		|r	||�|	r
|||�}
n|}
|||
|�\}}||z
}�,#ttf$rY||fSwxYw)NFT)r�r-rKrCrkr�r�r�)r�r�r�r'�self_expr_parse�self_skip_ignorables�check_ender�
try_not_enderrc�hasIgnoreExprsr��	tmptokenss            r6rTz_MultipleMatch.parseImpl�s����)�)�*�*��#�3�3�����>�>�%� �N�N�4�4�M��K���(�C�(�%�h��Z�@���V�	�%)�%5�%5�!5�5�N���!�(�C�0�!�1�(�C�@�F� �F�!0��6�:�!N���Y��)�#�����
�+�	���F�{��	�s�";B�B2�1B2c����tjr�tj|jvr�|jg|jj�zD]~}t
|t�s�|js�!tj|jvs�>d|�dt|�j�d|j�d�}tj|d��nt�|�9||�Sr;)r8rHrRrr�rr^rsr�r�r)rHr:r�rr=s     �r6rz_MultipleMatch._setResultsNames�����>�>��E�E��*�*�+��i�i�[�4�9�9�#4�#4�#6�6�
���q�-�0��
�
�#�M�M� �3�3�4�
1�15���T�$�Z�=P�=P�<Q�R*�*+�-�-�):�:R�T��
�M�M�'�a�8��
�"�w�&�t�-=�>�>rCr=�r��Union[str, ParserElement]rr�rr�rErFr�r�r�r�)r)r*r+r�rrTrr�r�s@r6r
r
�sS���?C�
�
>B�
�'�
�<�
�
;�
�
�

���:?�?rCr
c��eZdZdZdd�Zy)r�au
    Repetition of one or more of the given expression.

    Parameters:

    - ``expr`` - expression that must match one or more times
    - ``stop_on`` - (default= ``None``) - expression for a terminating sentinel
      (only required if the sentinel would ordinarily match the repetition
      expression)

    Example::

        data_word = Word(alphas)
        label = data_word + FollowedBy(':')
        attr_expr = Group(label + Suppress(':') + OneOrMore(data_word).set_parse_action(' '.join))

        text = "shape: SQUARE posn: upper left color: BLACK"
        attr_expr[1, ...].parse_string(text).pprint()  # Fail! read 'color' as data instead of next label -> [['shape', 'SQUARE color']]

        # use stop_on attribute for OneOrMore to avoid reading label string as part of the data
        attr_expr = Group(label + Suppress(':') + OneOrMore(data_word, stop_on=label).set_parse_action(' '.join))
        OneOrMore(attr_expr).parse_string(text).pprint() # Better -> [['shape', 'SQUARE'], ['posn', 'upper left'], ['color', 'BLACK']]

        # could also be written as
        (attr_expr * (1,)).parse_string(text).pprint()
    c�"�d|j�d�S)NrKz}...r�rs r6r,zOneOrMore._generateDefaultNameRs���D�I�I�;�e�$�$rCNr�)r)r*r+r,r,rYrCr6r�r�6s���6%rCr�c�R��eZdZdZ	ddd�							d�fd�Zd	d
�fd�
Zdd�Z�xZS)r�ap
    Optional repetition of zero or more of the given expression.

    Parameters:

    - ``expr`` - expression that must match zero or more times
    - ``stop_on`` - expression for a terminating sentinel
      (only required if the sentinel would ordinarily match the repetition
      expression) - (default= ``None``)

    Example: similar to :class:`OneOrMore`
    Nr?c�>��t�|�||xs|��d|_y)Nr?Tr%)r�r�rrr�s    �r6r�zZeroOrMore.__init__ds$���	����f�&7���8�!%��rCc���	t�|�|||�S#ttf$r|t	g|j
��fcYSwxYw)Nr6)r�rTr�r�r r�rs    �r6rTzZeroOrMore.parseImplnsK���	@��7�$�X�s�J�?�?���
�+�	@���R�d�.>�.>�?�?�?�	@�s��(?�?c�"�d|j�d�S)NrI�]...r�rs r6r,zZeroOrMore._generateDefaultNamets���4�9�9�+�T�"�"rCr=rLr�r�r�r=r�s@r6r�r�VsO���� ?C�&�
>B�&�'�&�<�&�
;�&�
�
&�@�#rCr�c�R��eZdZ				ddd�													d�fd�Zdd�Z�xZS)�
DelimitedListF)�allow_trailing_delimc���t|t�rtj|�}t	j
t|�}|�|dkrt
d��|�|�||krt
d��||_t|�|_	||_
||_|st|�|_
|xsd|_
||_||_|j|j|jz|jdz
|j�dn|jdz
fzz}|jr|t!|j�z
}|jrt#|�}t$�|�M|d��y)aaHelper to define a delimited list of expressions - the delimiter
        defaults to ','. By default, the list elements and delimiters can
        have intervening whitespace, and comments, but this can be
        overridden by passing ``combine=True`` in the constructor. If
        ``combine`` is set to ``True``, the matching tokens are
        returned as a single token string, with the delimiters included;
        otherwise, the matching tokens are returned as a list of tokens,
        with the delimiters suppressed.

        If ``allow_trailing_delim`` is set to True, then the list may end with
        a delimiter.

        Example::

            DelimitedList(Word(alphas)).parse_string("aa,bb,cc") # -> ['aa', 'bb', 'cc']
            DelimitedList(Word(hexnums), delim=':', combine=True).parse_string("AA:BB:CC:DD:EE") # -> ['AA:BB:CC:DD:EE']
        Nrzmin must be greater than 0z)max must be greater than, or equal to minTr�)r^r#rsr�r	rr��contentrt�	raw_delim�delim�combinerr�r]rWr��Combiner�r�)	r�r�r[r\r�r]rW�delim_list_exprr�s	        �r6r�zDelimitedList.__init__ys2���6�d�H�%� �4�4�T�:�D��{�{�=�$�/���?�s�Q�w��9�:�:��?�s��3��9��H�I�I�����U������
�����!�%��D�J��8�!������$8��!��,�,�$�*�*�t�|�|�*C��H�H�q�L��H�H�$�D�$�(�(�Q�,�H
�*
�
���$�$��s�4�:�:��.�O��<�<�%�o�6�O�
����4��8rCc�`�|jj�}|�d|j�d|�d�S)Nz [rrT)rYr�rZ)r��content_exprs  r6r,z"DelimitedList._generateDefaultName�s2���|�|�.�.�0����r�$�.�.�!1��<�.��E�ErC)r�FNN)r�rMr[rMr\rgr�r�r]r�rWrgrErFr�rFr�s@r6rVrVxsk���,/��$(�$(�
99�&+�99�'�99�)�99��	99�
"�99�"�
99�#�99�
�99�vFrCrVc��eZdZd�Zd�Zy)�
_NullTokenc��yrrYrs r6�__bool__z_NullToken.__bool__�s��rCc��y)NrfrYrs r6r7z_NullToken.__str__�s��rCN)r)r*r+rdr7rYrCr6rbrb�s���rCrbc�R��eZdZdZe�Zef					d�fd�
Zddd�Zdd�Z�xZ	S)	r�aO
    Optional matching of the given expression.

    Parameters:

    - ``expr`` - expression that must match zero or more times
    - ``default`` (optional) - value to be returned if the optional expression is not found.

    Example::

        # US postal code can be a 5-digit zip, plus optional 4-digit qualifier
        zip = Combine(Word(nums, exact=5) + Opt('-' + Word(nums, exact=4)))
        zip.run_tests('''
            # traditional ZIP code
            12345

            # ZIP+4 form
            12101-0001

            # invalid ZIP
            98765-
            ''')

    prints::

        # traditional ZIP code
        12345
        ['12345']

        # ZIP+4 form
        12101-0001
        ['12101-0001']

        # invalid ZIP
        98765-
             ^
        FAIL: Expected end of text (at char 5), (line:1, col:6)
    c�z��t�|�|d��|jj|_||_d|_y)NFr�T)r�r�r�r��defaultValuer�)r�r��defaultr�s   �r6r�zOpt.__init__�s8���	������.��)�)�.�.���#���!%��rCc��|j}	|j|||d��\}}||fS#ttf$rN|j}||j
ur,|jrt|g�}|||j<n|g}ng}Y||fSwxYw)NFr�)r�r-r�r�rh�_Opt__optionalNotMatchedr�r )r�r�r�r'�	self_exprrc�
default_values       r6rTz
Opt.parseImpl�s����I�I�	�
	�#�*�*��#�z��+��K�C���F�{����
�+�		� �-�-�M��D�$=�$=�=��(�(�)�=�/�:�F�4A�F�9�0�0�1�+�_�F�����F�{��		�s�*�AB�Bc���t|j�}t|�dkDrB|ddt|�dz
�dk(r+|dd}t|�dkDr|ddt|�dz
�dk(r�+d|�d�S)Nrrrir�rIr)rtr�rNrjs  r6r,zOpt._generateDefaultNamesx���D�I�I����%�j�1�n��q�':�C��J��N�':�!;�t�!C��!�B�K�E��%�j�1�n��q�':�C��J��N�':�!;�t�!C��5�'��|�rC)r�r�rirrErFr�r�r�)
r)r*r+r,rbrkr�rTr,r�r�s@r6r�r��s@���%�N&�<��?S�&�-�&�8;�&�	
�&��$rCr�c�`��eZdZdZ			ddd�											d	�fd�Zd�Z�fd�Zd
d�Z�xZS)r�a+

    Token for skipping over all undefined text until the matched
    expression is found.

    Parameters:

    - ``expr`` - target expression marking the end of the data to be skipped
    - ``include`` - if ``True``, the target expression is also parsed
      (the skipped text and target expression are returned as a 2-element
      list) (default= ``False``).
    - ``ignore`` - (default= ``None``) used to define grammars (typically quoted strings and
      comments) that might contain false matches to the target expression
    - ``fail_on`` - (default= ``None``) define expressions that are not allowed to be
      included in the skipped test; if found before the target expression is found,
      the :class:`SkipTo` is not a match

    Example::

        report = '''
            Outstanding Issues Report - 1 Jan 2000

               # | Severity | Description                               |  Days Open
            -----+----------+-------------------------------------------+-----------
             101 | Critical | Intermittent system crash                 |          6
              94 | Cosmetic | Spelling error on Login ('log|n')         |         14
              79 | Minor    | System slow when running too many reports |         47
            '''
        integer = Word(nums)
        SEP = Suppress('|')
        # use SkipTo to simply match everything up until the next SEP
        # - ignore quoted strings, so that a '|' character inside a quoted string does not match
        # - parse action will call token.strip() for each matched token, i.e., the description body
        string_data = SkipTo(SEP, ignore=quoted_string)
        string_data.set_parse_action(token_map(str.strip))
        ticket_expr = (integer("issue_num") + SEP
                      + string_data("sev") + SEP
                      + string_data("desc") + SEP
                      + integer("days_open"))

        for tkt in ticket_expr.search_string(report):
            print tkt.dump()

    prints::

        ['101', 'Critical', 'Intermittent system crash', '6']
        - days_open: '6'
        - desc: 'Intermittent system crash'
        - issue_num: '101'
        - sev: 'Critical'
        ['94', 'Cosmetic', "Spelling error on Login ('log|n')", '14']
        - days_open: '14'
        - desc: "Spelling error on Login ('log|n')"
        - issue_num: '94'
        - sev: 'Cosmetic'
        ['79', 'Minor', 'System slow when running too many reports', '47']
        - days_open: '47'
        - desc: 'System slow when running too many reports'
        - issue_num: '79'
        - sev: 'Minor'
    N)�failOnc�T��t�|�|�|xs|}||_d|_d|_||_d|_t|t�r|j|�|_
n||_
d|j��|_t�j�|_|j!�y)NTFzNo match found for )r�r��
ignoreExprr�r��includeMatchr�r^r#r�rpr�r�r�r�ignorer�_update_ignorer)r�r��includer#�fail_onrpr�s      �r6r�zSkipTo.__init__Ns����	������"�7�� ���!%���"���#�������f�h�'��2�2�6�:�D�K� �D�K�+�D�I�I�;�7����w�/�/�1������rCc��|jjj�|jjD]}|jj	|��|j
r&|jj	|j
�yyr=)rtr�r6r�r#rr)r�rFs  r6ruzSkipTo._update_ignorerfse����� � �&�&�(����&�&�	#�A��L�L����"�	#��?�?��L�L������0�rCc�D��t�|�|�|j�yr=)r�r#rurs  �r6r#z
SkipTo.ignorens���
���t�����rCc�Z�|}t|�}|jj}|j�|jjnd}|j
jr|j
jnd}|}	|	|kr2|�
|||	�rn>|�|	}
		|||	�}	|	|
k(rn|	}
�	|||	dd��nt|||j|��|	}|||}t|�}|jr||||d��\}}
||
z
}||fS#t$rY�gwxYw#ttf$r|	dz
}	YnwxYw|	|kr���~)NrF)r'r(r�)rNr�r-rpr�rtr�rkr�r�r�r�r rs)r�r�r�r'r�rOrE�self_failOn_canParseNext�ignorer_try_parse�tmploc�prev_tmploc�skiptext�
skipresultr@s              r6rTzSkipTo.parseImplrsn�����x�=���)�)�*�*��(,���(?�D�K�K�$�$�T�	!�7;�l�l�6N�6N�D�L�L�2�2�TX������ �'�3�+�H�f�=�� �,�$����!2�8�V�!D����,��"(�K��
���&�U�QV�W��!��3����T�B�B����H�S�)��!�(�+�
����&�x��j�u�U�H�C���#��J��J����;.�����#�J�/�
��!���
��+�� �s$�	C=�"D�=	D	�D	�D#�"D#)FNN)r�r�rvrgr#r�rwr�rpr�rErFr�)	r)r*r+r,r�rur#rTr�r�s@r6r�r�sm���;�@�=A�>B��>B��(����;�	�
<��;��
��01��3rCr�c����eZdZdZ	d			d�fd�
Zdd�Zdd�Zd�fd�Zd�Zdd�fd�
Z	ddd�Z
ddd	�Zdd
�Zddd�Z
dd�Zd�fd
�Zdd�fd�
Zede
�Zede�Z�xZS)r�aw
    Forward declaration of an expression to be defined later -
    used for recursive grammars, such as algebraic infix notation.
    When the expression is known, it is assigned to the ``Forward``
    variable using the ``'<<'`` operator.

    Note: take care when assigning to ``Forward`` not to overlook
    precedence of operators.

    Specifically, ``'|'`` has a lower precedence than ``'<<'``, so that::

        fwd_expr << a | b | c

    will actually be evaluated as::

        (fwd_expr << a) | b | c

    thereby leaving b and c out as parseable alternatives.  It is recommended that you
    explicitly group the values inserted into the ``Forward``::

        fwd_expr << (a | b | c)

    Converting to use the ``'<<='`` operator instead will avoid this problem.

    See :class:`ParseResults.pprint` for an example of a recursive
    parser created using ``Forward``.
    c�r��tjd��d|_t�|�|d��d|_y)NrSr�rFr�)r�r��caller_framer�r��lshift_liner�s  �r6r�zForward.__init__�s7���&�3�3�!�<�Q�?���
������/���rCc��t|d�r|`t|t�r|j	|�}t|t
�stS||_|j|_|jj|_	|jj|_|j|jj|jj��|jj|_|jj |_|j"j%|jj"�t'j(d��d|_|S)Nr�r�rSr����)r.r�r^r#r�rsr�r�r�r�rr�rr�r�r�r�r�rr�r�r�r�s  r6�
__lshift__zForward.__lshift__�s���4��(��!��e�X�&��,�,�U�3�E��%��/�!�!���	� �,�,���!�Y�Y�4�4���!%���!9�!9����!�!��I�I� � ��	�	�0O�0O�	"�	
�#�i�i�6�6����)�)�.�.���������	�	� 5� 5�6�$�2�2��;�B�?����rCc�8�t|t�stS||zSr=)r^rsr�r�s  r6�__ilshift__zForward.__ilshift__�s���%��/�!�!��u�}�rCc���tjd��d}tjrB||jk(r3t
j|jvrtjdd��t�|�)|�}|S)NrSr�r�zfwarn_on_match_first_with_lshift_operator: using '<<' operator with '|' is probably an error, use '<<='rF)r�r�r8rMr�rRrrHr:r�r�)r�r��caller_liner�r�s    �r6r�zForward.__or__�sr����-�-�A�6�r�:���=�=��t�/�/�/��D�D��*�*�+�
�M�M�P��
�
�g�n�U�#���
rCc��|j�ttjrctj|jvrFtjdt|jj|jj��yyyy)Nzhwarn_on_assignment_to_Forward: Forward defined here but no expression attached later using '<<=' or '<<')�filenamer�)r�r8rKrRrrH�
warn_explicit�UserWarningr�r�r�rs r6�__del__zForward.__del__�sp��
�I�I���6�6��9�9��AX�AX�X��"�"�]���*�*�3�3��(�(�/�/�
�Y�7�
rCc	���|j��tjr�tj|jvrdd}tjd��}tt|�d��D]\}}|j|vs�|dz}nd}tjd|��tjst�|�=|||�Stj 5tj"}		|	|||f\}
}t%|t&�r|�|
|j)�fcddd�S#t*$�r||d	f}||d
f}
|dz
t-||d|�fx\}
}|	|
<|r|	|
|	|<		t�|�=||d
�\}}n$#t,$rt%|t&�r�|
|}}YnwxYw||
kr\|r5|	|x\}
}|	|
<|	|
=|	|=|
t)j(|�fcYcddd�S|	|
=|
t)j(|�fcYcddd�S|r4	t�|�=||d	�|	|<n#t,$r}||fx|	|
<|	|<�d}~wwxYw||fx\}
}|	|
<��wxYw#1swYyxYw)N)r�r�r�r���r�r)r�rSzjwarn_on_parse_using_empty_Forward: Forward expression was never assigned a value, will not parse any inputrFTFz#Forward recursion without base case)r�r8rJrRrr�r�r:�reversedrArHr:rsr�r�rTr�rnr^r]r�KeyErrorr�)r�r�r�r'�	parse_fnsr�rd�frmrG�memo�prev_loc�prev_result�act_key�peek_key�	prev_peek�new_loc�new_peekrFr�s                  �r6rTzForward.parseImpls�����I�I���:�:��=�=��*�*�+��I��(�(�s�3�B�#�H�R�L��:�
���3��8�8�y�(�!"�Q��J��
�
�
��M�M�[�%�
�
�4�4��7�$�X�s�J�?�?�(�
)�
)�.	M� �0�0�D�,
M�(,�S�$�
�-B�(C�%��+��k�9�5�%�%���!1�!1�!3�3�.	M�.	M���&
M���d�+����u�-���!�G�"� �#�'L�d��8��#��)�d�8�n��$(��N�D��M��@�,1�G�,=�h��U�,S�)����)�@�%�i��;�!�,4�i���	@���(�*�%�FJ�'�]�R�1�H�k�D��N� $�X���W�
�#+�T�Y�Y�{�-C�#C�C�I.	M�.	M�J!��N�'����9�)=�=�=�M.	M�.	M�P"�"�,1�G�,=�h��T�,R�D��M��-�"�>E�q�\�I�D��N�T�'�]�!��"��<C�H�;L�L�'�H�i�$�x�.�3�&
M��.	M�.	M�s~�H5�!.D�:H2�E)�(H2�)F
�H2�	F
�
4H2�>H5�	H2�#H5�.H2�1H�H2�	H!�
H�H!�!H2�2H5�5H>c��d|_|Srrrs  r6rzForward.leave_whitespacefs��#����rCc��d|_|Sr<rrs  r6rzForward.ignore_whitespacejs��"����rCc�x�|js-d|_|j�|jj�|Sr<)r�r�r�rs r6r�zForward.streamlinens2�����#�D���y�y�$��	�	�$�$�&��rCc���tjdtd��|�g}||vr0|dd|gz}|j�|jj	|�|jg�yr7r�r�s   r6rKzForward.validateusg���
�
�h���	
�
� ��M��}�$���"�d�V�+�C��y�y�$��	�	�"�"�3�'����R� rCc���|j}d|_	|j�t|j�dd}nd}||_t	|�j
�d|��S#t$rd}Y�.wxYw)Nz: ...i�rFr�rh)r�r�rtr]r�r))r��save_default_name�
ret_strings   r6r,zForward._generateDefaultName�sz�� �-�-��#���	��y�y�$� ����^�E�T�2�
�#�
�.����t�*�%�%�&�b���5�5��	�	��J�	�s�'A�A+�*A+c�Z��|j�t�|�	�St�}||z}|Sr=)r�r�rr�)r�r�r�s  �r6rzForward.copy�s.����9�9� ��7�<�>�!��)�C��D�L�C��JrCc���tjr[tj|jvr?|j�3d|�dt|�j�d�}tj|d��t�|�)||�S)Nz5warn_name_set_on_empty_Forward: setting results name r<z, expression that has no contained expressionrTrF)r8rIrRrr�r�r)rHr:r�rr�s    �r6rzForward._setResultsName�s|���
�3�3��:�:�$�BY�BY�Y��	�	�!�)�)-���T�$�Z�5H�5H�4I�J4�4�
�

�M�M�'�a�0��w�&�t�-=�>�>rCr�r�r=)r�r�rErF)rEr�r�r�r�r�rDr�r�)r)r*r+r,r�r�r�r�r�rTrrr�rKr,rrrr�r�r�r�s@r6r�r��s�����:CG� �?� �	
� ��,�� 
�]M�~���
!�6�"�?�&'�'8�:J�K�O�'�(:�<M�N�rCr�c�&��eZdZdZdd�fd�
Z�xZS)�TokenConverterz[
    Abstract subclass of :class:`ParseElementEnhance`, for converting parsed results.
    c�2��t�|�|�d|_yr)r�r�r��r�r�rr�s   �r6r�zTokenConverter.__init__�s���
�������rCr�rr0r�s@r6r�r��s���� � rCr�c�T��eZdZdZ		ddd�									d�fd�Zd	�fd�Zd�Z�xZS)
r]a�Converter to concatenate all matching tokens to a single string.
    By default, the matching patterns must also be contiguous in the
    input string; this can be disabled by specifying
    ``'adjacent=False'`` in the constructor.

    Example::

        real = Word(nums) + '.' + Word(nums)
        print(real.parse_string('3.1416')) # -> ['3', '.', '1416']
        # will also erroneously match the following
        print(real.parse_string('3. 1416')) # -> ['3', '.', '1416']

        real = Combine(Word(nums) + '.' + Word(nums))
        print(real.parse_string('3.1416')) # -> ['3.1416']
        # no match when there are internal spaces
        print(real.parse_string('3. 1416')) # -> Exception: Expected W:(0123...)
    N)�
joinStringc���t�|�|�|�|n|}|r|j�||_d|_||_d|_yr<)r�r�r�adjacentr�r�r�)r�r��join_stringr�r�r�s     �r6r�zCombine.__init__�sK���	�����#-�#9�Z�{�
���!�!�#� ��
�"���$��� ��rCc�n��|jrtj||�|St�|�	|�|Sr=)r�rsr#r�r�s  �r6r#zCombine.ignore�s4����=�=�� � ��u�-���
�G�N�5�!��rCc���|j�}|dd�=|tdj|j|j��g|j
��z
}|jr|j�r|gS|S)Nrf)r\)rr r��
_asStringListr�r�r��haskeys)r�r�r�rX�retTokss     r6rYzCombine.postParse�sm���.�.�"���A�J��<�
�W�W�Y�,�,�T�_�_�=�
>�?�t�GX�GX�
�	
�������� 1��9���NrC)rfT)
r�rsr�rtr�rgr�r�rErFr�)r)r*r+r,r�r#rYr�r�s@r6r]r]�sY����*��	!�,0�
!��!��!��	!�)�
!�
�!�$�
rCr]c�,��eZdZdZdd�fd�
Zd�Z�xZS)r
a�Converter to return the matched tokens as a list - useful for
    returning tokens of :class:`ZeroOrMore` and :class:`OneOrMore` expressions.

    The optional ``aslist`` argument when set to True will return the
    parsed tokens as a Python list instead of a pyparsing ParseResults.

    Example::

        ident = Word(alphas)
        num = Word(nums)
        term = ident | num
        func = ident + Opt(DelimitedList(term))
        print(func.parse_string("fn a, b, 100"))
        # -> ['fn', 'a', 'b', '100']

        func = ident + Group(Opt(DelimitedList(term)))
        print(func.parse_string("fn a, b, 100"))
        # -> ['fn', ['a', 'b', '100']]
    c�@��t�|�|�d|_||_yr<)r�r�r��
_asPythonList)r�r��aslistr�s   �r6r�zGroup.__init__
����
��������#��rCc��|jrBtjt|t�r|j	��St|��S|gSr=)r�r �Listr^r[r�rWs    r6rYzGroup.postParsesS������$�$��i��6�� � �"��
��)�_��
��{�rCr�)r�rsr�rgrErF�r)r*r+r,r�rYr�r�s@r6r
r
�s����($�
rCr
c�,��eZdZdZdd�fd�
Zd�Z�xZS)�DictarConverter to return a repetitive expression as a list, but also
    as a dictionary. Each element can also be referenced using the first
    token in the expression as its key. Useful for tabular report
    scraping when the first column can be used as a item key.

    The optional ``asdict`` argument when set to True will return the
    parsed tokens as a Python dict instead of a pyparsing ParseResults.

    Example::

        data_word = Word(alphas)
        label = data_word + FollowedBy(':')

        text = "shape: SQUARE posn: upper left color: light blue texture: burlap"
        attr_expr = (label + Suppress(':') + OneOrMore(data_word, stop_on=label).set_parse_action(' '.join))

        # print attributes as plain groups
        print(attr_expr[1, ...].parse_string(text).dump())

        # instead of OneOrMore(expr), parse using Dict(Group(expr)[1, ...]) - Dict will auto-assign names
        result = Dict(Group(attr_expr)[1, ...]).parse_string(text)
        print(result.dump())

        # access named fields as dict entries, or output as dict
        print(result['shape'])
        print(result.as_dict())

    prints::

        ['shape', 'SQUARE', 'posn', 'upper left', 'color', 'light blue', 'texture', 'burlap']
        [['shape', 'SQUARE'], ['posn', 'upper left'], ['color', 'light blue'], ['texture', 'burlap']]
        - color: 'light blue'
        - posn: 'upper left'
        - shape: 'SQUARE'
        - texture: 'burlap'
        SQUARE
        {'color': 'light blue', 'posn': 'upper left', 'texture': 'burlap', 'shape': 'SQUARE'}

    See more examples at :class:`ParseResults` of accessing fields by results name.
    c�@��t�|�|�d|_||_yr<)r�r�r��
_asPythonDict)r�r��asdictr�s   �r6r�z
Dict.__init__Gr�rCc���t|�D]�\}}t|�dk(r�|d}t|t�rt	|�j�}t|�dk(rt
d|�||<�at|�dk(r&t|dt�st
|d|�||<��	|j�}|d=t|�dk7s t|t�r |j�rt
||�||<��t
|d|�||<��|jr-|jr|j�gS|j�S|jr|gS|S#t$rtd�}|d�wxYw)NrrrfrSzdcould not extract dict values from parsed results - Dict expression must contain Grouped expressions)r:rNr^r�rtrjr!r rr]r�r�r�r��as_dict)	r�r�r�rXrd�tok�ikey�	dictvaluer�s	         r6rYzDict.postParseLsf���	�*�	O�F�A�s��3�x�1�}���q�6�D��$��$��4�y���(���3�x�1�}�"9�"�a�"@�	�$���S��Q��z�#�a�&�,�'G�"9�#�a�&�!�"D�	�$��(� #���
�I��a�L��y�>�Q�&��y�,�7�I�<M�<M�<O�&=�i��&K�I�d�O�&=�i��l�A�&N�I�d�O�?	O�B���,0�,<�,<�I�%�%�'�(�U�)�BS�BS�BU�U�"�.�.�	�{�=�I�=��'!�(�#�N��C��4�'�(�s�"E�E)r�)r�rsr�rgrErFr�r�s@r6r�r�s���'�R$�
%>rCr�c�L��eZdZdZdd�fd�
Zd	�fd�Zd	�fd�Zd�Zd	d�Z�xZ	S)
ra�Converter for ignoring the results of a parsed expression.

    Example::

        source = "a, b, c,d"
        wd = Word(alphas)
        wd_list1 = wd + (',' + wd)[...]
        print(wd_list1.parse_string(source))

        # often, delimiters that are useful during parsing are just in the
        # way afterward - use Suppress to keep them out of the parsed output
        wd_list2 = wd + (Suppress(',') + wd)[...]
        print(wd_list2.parse_string(source))

        # Skipped text (using '...') can be suppressed as well
        source = "lead in START relevant text END trailing text"
        start_marker = Keyword("START")
        end_marker = Keyword("END")
        find_body = Suppress(...) + start_marker + ... + end_marker
        print(find_body.parse_string(source)

    prints::

        ['a', ',', 'b', ',', 'c', ',', 'd']
        ['a', 'b', 'c', 'd']
        ['START', 'relevant text ', 'END']

    (See also :class:`DelimitedList`.)
    c�R��|durtt��}t�|�
|�y)N.)r�rr�r�r�s   �r6r�zSuppress.__init__�s#����3�;���	�*�D�
����rCc���t|jt�rtt	|��|zSt
�|�|�Sr=)r^r�r�rr�r�r�r�s  �r6r�zSuppress.__add__��4����d�i�i��.��F�5�M�*�U�2�2��w��u�%�%rCc���t|jt�rtt	|��|z
St
�|�|�Sr=)r^r�r�rr�r�r�r�s  �r6r�zSuppress.__sub__�r�rCc��gSr=rYrWs    r6rYzSuppress.postParse�r>rCc��|Sr=rYrs r6rzSuppress.suppress�s���rCr�r�r�)
r)r*r+r,r�r�r�rYrr�r�s@r6rrts!����<�
&�&��rCrc�J��t����fd�}�j|_|S)asDecorator for debugging parse actions.

    When the parse action is called, this decorator will print
    ``">> entering method-name(line:<current_source_line>, <parse_location>, <matched_tokens>)"``.
    When the parse action completes, the decorator will print
    ``"<<"`` followed by the returned value, or any exception that the parse action raised.

    Example::

        wd = Word(alphas)

        @trace_parse_action
        def remove_duplicate_chars(tokens):
            return ''.join(sorted(set(''.join(tokens))))

        wds = wd[1, ...].set_parse_action(remove_duplicate_chars)
        print(wds.parse_string("slkdjs sld sldd sdlf sdljf"))

    prints::

        >>entering remove_duplicate_chars(line: 'slkdjs sld sldd sdlf sdljf', 0, (['slkdjs', 'sld', 'sldd', 'sdlf', 'sdljf'], {}))
        <<leaving remove_duplicate_chars (ret: 'dfjkls')
        ['dfjkls']
    c�����j}|dd\}}}t|�dkDrt|d�j�d|��}tjjd|�dt
||��d|�d|�d�	�	�|�}tjjd	|�d|�d��|S#t$rB}tjjd	|�d
t|�j�d|�d���d}~wwxYw)
N���rTr�.z>>entering z(line: rlz)
z
<<leaving z
 (exception: rhz (ret: )r)rNr�rn�stderrrpr�r])�paArgs�thisFuncr�r�r�r�r�rUs       �r6�zztrace_parse_action.<locals>.z�s�����:�:�����+���1�a��v�;��?��v�a�y�/�2�2�3�1�X�J�?�H��
�
���;�x�j���Q��
�~�R��s�"�Q�E�QT�U�V�	��V�*�C�	�
�
���:�h�Z�w�s�g�S�A�B��
��
�	��J�J����X�J�m�D��I�4F�4F�3G�r�#��c�R�
�
��		�s�9B&�&	C1�/=C,�,C1)r�r))rUr�s` r6�trace_parse_actionr��s%���2	�A��A�� ���A�J��HrC�empty�
line_start�line_end�string_start�
string_endz\\[\\[\]\/\-\*\.\$\+\^\?()~ ]c��|ddSrrYr-s   r6r�r��s��A�a�D��G�rCz\\0?[xX][0-9a-fA-F]+c�P�tt|djd�d��S)Nrz\0xrh)r�r�rtr-s   r6r�r��s��C��A�a�D�K�K��/��4�5�rCz	\\0[0-7]+c�8�tt|dddd��S)Nrrr�)r�r�r-s   r6r�r��s��C��A�a�D���H�a�(�)�rCz\])r^rErIr��negate�bodyrc	���d�}	djtj|�jD��cgc]}||�D]}|���c}}�Scc}}w#t$r
}Yd}~yd}~wwxYw)a	Helper to easily define string ranges for use in :class:`Word`
    construction. Borrows syntax from regexp ``'[]'`` string range
    definitions::

        srange("[0-9]")   -> "0123456789"
        srange("[a-z]")   -> "abcdefghijklmnopqrstuvwxyz"
        srange("[a-z$_]") -> "abcdefghijklmnopqrstuvwxyz$_"

    The input string must be enclosed in []'s, and the returned string
    is the expanded character set joined into a single string. The
    values enclosed in the []'s may be:

    - a single character
    - an escaped character with a leading backslash (such as ``\-``
      or ``\]``)
    - an escaped hex character with a leading ``'\x'``
      (``\x21``, which is a ``'!'`` character) (``\0x##``
      is also supported for backwards compatibility)
    - an escaped octal character with a leading ``'\0'``
      (``\041``, which is a ``'!'`` character)
    - a range of any of the above, separated by a dash (``'a-z'``,
      etc.)
    - any combination of the above (``'aeiouy'``,
      ``'a-zA-Z0-9_$'``, etc.)
    c3�K�t|t�r7d�tt|d�t|d�dz�D�Ed{���y|��y7�
�w)Nc3�2K�|]}t|����y�wr=)r�r�s  r6r�z,srange.<locals>._expanded.<locals>.<genexpr>s����H�1��A��H�r4rr)r^r r��ord)�ps r6�	_expandedzsrange.<locals>._expandedsD�����a��&�H��c�!�A�$�i��Q�q�T��Q��(G�H�H�H��G�
I�s�AA�A�ArfN)r��_reBracketExprr�r�r])r�r��partr�rFs     r6�sranger��sc��6���w�w�)�6�6�q�9�>�>�X�4�	�RV��X�1�Q�X�Q�X�
�	
��X�������s"�-A�A
�A�A�	A)�$A)c�f�����fd�}t�dt�d�j�}||_|S)a^Helper to define a parse action by mapping a function to all
    elements of a :class:`ParseResults` list. If any additional args are passed,
    they are forwarded to the given function as additional arguments
    after the token, as in
    ``hex_integer = Word(hexnums).set_parse_action(token_map(int, 16))``,
    which will convert the parsed data to an integer using base 16.

    Example (compare the last to example in :class:`ParserElement.transform_string`::

        hex_ints = Word(hexnums)[1, ...].set_parse_action(token_map(int, 16))
        hex_ints.run_tests('''
            00 11 22 aa FF 0a 0d 1a
            ''')

        upperword = Word(alphas).set_parse_action(token_map(str.upper))
        upperword[1, ...].run_tests('''
            my kingdom for a horse
            ''')

        wd = Word(alphas).set_parse_action(token_map(str.title))
        wd[1, ...].set_parse_action(' '.join).run_tests('''
            now is the winter of our discontent made glorious summer by this sun of york
            ''')

    prints::

        00 11 22 aa FF 0a 0d 1a
        [0, 17, 34, 170, 255, 10, 13, 26]

        my kingdom for a horse
        ['MY', 'KINGDOM', 'FOR', 'A', 'HORSE']

        now is the winter of our discontent made glorious summer by this sun of york
        ['Now Is The Winter Of Our Discontent Made Glorious Summer By This Sun Of York']
    c�<��|D�cgc]}�|g������
c}Scc}wr=rY)r�r�r��toknr�r�s    ��r6r�ztoken_map.<locals>.paDs!���./�0�d��T�!�D�!�0�0��0s�r)r�)r�r))r�r�r�r�s``  r6�	token_mapr�s2���J1���j�'�$��*D�*M�*M�N�I��B�K�
�IrCc�(�ttdd��}|d�}|�ytjtj
|�}|jj�D]4\}}t|t�s�|jr�$|j|��6y)zy
    Utility to simplify mass-naming of parser elements, for
    generating railroad diagram with named subdiagrams.
    �	_getframec��yr=rY)r(s r6r�z#autoname_elements.<locals>.<lambda>Tr�rCrN)r�rnr	r�types�	FrameType�f_localsr�r^rsr�r1)�getframe_fn�
calling_framerA�vars    r6�autoname_elementsr�Msx���#�{�N�;�K���N�M�����K�K�����?�M�"�+�+�1�1�3��	��c��c�=�)�#�.�.��L�L���rCz4"(?:[^"\n\r\\]|(?:"")|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*�"z string enclosed in double quotesz4'(?:[^'\n\r\\]|(?:'')|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*�'z string enclosed in single quoteszdouble quoted stringzsingle quoted stringz+quoted string using single or double quotesz""""(?:[^"\\]|""(?!")|"(?!"")|\\.)*r�z"""zmultiline double quoted stringz"'''(?:[^'\\]|''(?!')|'(?!'')|\\.)*z'''zmultiline single quoted stringz5"(?:[^"\n\r\\]|(?:\\")|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*z5'(?:[^'\n\r\\]|(?:\\')|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*zPython quoted stringr�zunicode string literalz#[\0xc0-\0xd6\0xd8-\0xf6\0xf8-\0xff]z[\0xa1-\0xbf\0xd7\0xf7]r�r��nullDebugAction�traceParseAction�conditionAsParseAction�tokenMap)r\rRrErFrD)riztyping.Iterable[str]rjr�rErg)rTr)r�r�r�r�r�rgrEr�r�)r�rtr�r�r�rsr�rg)r�rtr�r�r�r�r�rsr�r r�rg)
r�rtr�r�r�rsr�r]r�rg)rUr�rEr�r�)rEr�)��
__future__r�collections.abc�collectionsr�osr	rrrrr	r
rr�abcr
r�enumr�stringrrHrTrnrr�r��operatorr�	functoolsr�	threadingr�pathlibr�utilrrrrrrrr�rr�r�
exceptions�actionsrAr r!�unicoder"�maxsizer�rt�bytesr#r�r$r&r8rRr]r`rBrq�warnoptions�environr8�sumrNrNr�r�r�r�r)r7r�r]r��
GeneratorTyper'r�r��PostParseReturnTypergr�r]r�r�r�r��ascii_uppercase�ascii_lowercaseru�Latin1rvrwryr{r|r��	printable�
whitespacer}rr�r�r�r�r�r�r�r�rsr�r�rrmr�r�r�rr)r.r2rCrsrwr�r�r�r�r�r�r�rr�rrrr#r�r�r�r�r�rWrrr#r)r5rr
r�r�rVrbr�rr�r�r�r]r
r�rr�r1r�r�r�r�r�r<�_escapedPunc�_escapedHexChar�_escapedOctChar�_singleChar�
_charRanger r�r�r�r��dbl_quoted_string�sgl_quoted_stringrrr��python_quoted_string�unicode_string�
alphas8bit�punc8bitrY�valuesr^r��sglQuotedString�dblQuotedString�quotedString�
unicodeString�	lineStart�lineEnd�stringStart�	stringEndr�r�r�r�)r�r�s00r6�<module>r.s0
��#���	�
�	�	�	�$��
���	�
�$�������
�
�
���:�&��;�;��!�5�\��
�)�2&����.�~��,*�$�*�D$�%�#���/��?S��	��"��O�O�R�Z�Z�^�^�$@�A������f�h��e�S�#�s�C����
�$�$���C��H�o���L�(�<�*@�@�A����R��X���l�^�T�
!�"��c�<�
 �$�
&�'��c�3��
%�t�
+�,�.����C��o�y�A�4�G�H���S�#���=�t�C�D����#�s�O�\�4�8�$�>��� ��c�?�I�t� L�d� R�S���$�$�v�'=�'=�=���=�#�*�*�5�5�
�C�5�'�.�.�=�=���=���c���n�$���$��$��	�3���'�'�f�&6�&6�U��!�6�CT�CT�:T�1�U�V�
�C�V�	&�Y�	&�15��-�4���=�BMR����!5��EI����:EJ�
��
��
�#0�
�=A�
�&�
	@��	@��	@�
�	@��		@�
�	@��
	@�"�U��U�	�U��U�
�	U�
�U�R�q�C�q�j=&
�=�&
�R	#�M�	#�?�e�?�2?�e�2?�j�G��"?��?�%,�
�!�r�e�r�j?�g�?�6B�g�B�2T?��T?�nx#�5�x#�v
�4�
�,C)�E�C)�Li�5�i�XM(��M(�`L(�E�L(�^#�E�#����D.?�
�.?�bC�m�C�.�-��"?�
�?�(�
��8�m��:(K�%�(K�ViO�m�iO�Ze�/�e�P[?��[?�|k?��k?�\m?�?�m?�`jO�-�jO�\=
�'�=
�@<�'�<�*<�%�<�B!�$�!�HN�$�N�b'#�!�'#�T(#�
 �(#�VJ?�(�J?�Z%��%�@#��#�D>F�'�>F�B��I�
�I�X��U�
 �U�pIO�!�IO�Z �(� �6�n�6�r"�N�"�JT>�>�T>�n4�~�4�n,
�`	�����!��
�[�
!�
!�,�
/�
��9���j�)���}�%�%�n�5��
�[�
!�
!�,�
/�
��5�6�G�G�����/�0�A�A�5�����%�6�6�)����?�"�_�4�z�%�q�7Q�Q���;��#��.��<�
=�
��C�L�	�#�h����)�*��I�j�;�.�/�0�A�A�&�I�J��c�l���&�R+�\�(�	�
A�B�S�H��
�(�-�.���	�
A�B�S�H��
�(�-�.���
�B�C�c�I�S�S���
�
D�E��K�U�U������(�8�9���
�0����E��M�W�W�(��	�3�2�<�<�H�5�P��h�/�0�1�
�
E�F��L�V�V���
�
�
E�F��L�V�V����
��(�!�"����}�1�1�3�3�4�=�=�>V�W���:�
;�
��,�-��
�v�}�}��'�
�*�Q�
�">�A�'��#��$��#�����
��	�
�����	�"�#4�6G�H��#�$6�8J�K��)�*B�D]�^���J�	�2���Y}V��v|'s�._;�_;�+`�:`