%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/pyparsing/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/pyparsing/__pycache__/core.cpython-312.pyc

�

&
�d$u�
���UddlmZddlZddlZddlmZmZmZmZmZm	Z	m
Z
mZmZm
Z
mZddlmZmZddlmZddlZddlZddlZddlZddlZddlmZddlZddlZddlmZddlm Z dd	l!m"Z"dd
l#m$Z$ddl%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z.m/Z0m1Z1dd
l2�dd
l3�ddl4m5Z5m6Z6ddl7m8Z8ejrZ:e;e<fZ=ee>dfe?d<ej�dk\rddlmAZAn
Gd�d�ZAGd�de(�ZBGd�de(�ZCGd�de�ZDdeDddfd�ZEdeDddfd�ZFd�d �ZG[(d!ej4e;d"ej�e;deIfd#�ZJeJej�ej�j�d$��reG�eNeOePeQeReSeTeUeVeWeXhZYej�Z[ee\efZ]e
e5e	e5fZ^e
egefee5gefee\e5gefee;e\e5geffZ_e
egeIfee5geIfee\e5geIfee;e\e5geIffZ`ee;e\d%eagdfZbee;e\d%eIgdfZcee;e\e\d%e5eIgdfZdee;e\d%eaeIgdfZeej�ej�zZhe8j�j�Zje8j�j�Zkd&Zleld'zZmehelzZnd(j�ej�D�cgc]}|ej�vs�|��c}�Zrdasej�e?d)<d�d*�Zu	d�d+e`d,ej�e;d-eIde_fd.�Zv	d�d/e;d0e\d1d%d2eIfd3�Zw	d�d/e;d4e\d5e\d1d%d6e5d2eIfd7�Zx	d�d/e;d0e\d1d%d8ead2eIf
d9�Zyd:�ZzGd;�d%e�Z{Gd<�d=e{�Z|Gd>�d?e{�Z}Gd@�dAe}�Z~GdB�dCe}�ZGdD�dEe�Z�GdF�dGe�Z�ee{_�GdH�dIe}�Z�GdJ�dKe�Z�GdL�dMe��Z�GdN�dOe}�Z�GdP�dQe}�Z�GdR�dSe��Z�GdT�dUe}�Z�GdV�dWe}�Z�GdX�dYe}�Z�GdZ�d[e}�Z�Gd\�d]e}�Z�Gd^�d_e��Z�Gd`�dae��Z�Gdb�dce��Z�Gdd�dee��Z�Gdf�dge��Z�Gdh�die��Z�Gdj�dke��Z�Gdl�dme{�Z�Gdn�doe��Z�Gdp�dqe��Z�Gdr�dse��Z�Gdt�due��Z�Gdv�dwe{�Z�Gdx�dye��Z�Gdz�d{e��Z�Gd|�d}e��Z�Gd~�de��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�ZHGd��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�e_de_fd��Z�e���jad��Z�e���jad��Z�e���jad��Z�e���jad��Z�e���jad��Z�e�d���jmd���Z�e�d���jmd���Z�e�d���jmd���Z�e�e�ze�ze�d�d���zZ�e�e�e�d��ze�z�Z�ed��e�d���jyd��ze�e�e�e�z���jyd��zed��zZ�d�e;de;fd��Z�de_fd��Z�d�d��Z�e�e�d��d�z��jad��Z�e�e�d��d�z��jad��Z�e�e�d��d�z�jad��e�d��d�z�jad��z��jad��Z�e�e�d�e�j��ëd�z�jadūe�d�e�j��ëd�z�jadȫze�dɫd�z�jad��ze�dʫd�z�jad��z��jad˫Z�e�d�e�j+�z��jadͫZ�e�dΫZ�e�dϫZ�eɫ�j��D�cgc]}e�|e{�s�
|��c}Z�ee{e?d�<e�Z�e�Z�e�Z�e�Z�e�Z�e�Z�e�Z�e�Z�e1ez�dф�Z�e1e��d҄�Z�e1ev�dӄ�Z�e1e��dԄ�Z�ycc}wcc}w)��)�dequeN)�Any�Callable�	Generator�List�
NamedTuple�Sequence�Set�TextIO�Tuple�Union�cast)�ABC�abstractmethod)�Enum)�Iterable)�
itemgetter)�wraps)�RLock)�Path�)
�
_FifoCache�_UnboundedCache�__config_flags�_collapse_string_to_ranges�_escape_regex_range_chars�_bslash�_flatten�LRUMemo�
UnboundedMemo�replaced_by_pep8)�*)�ParseResults�_ParseResultsWithOffset)�pyparsing_unicode.�str_type)��)�cached_propertyc��eZdZd�Zdd�Zy)r)c��||_y�N)�_func)�self�funcs  �0/usr/lib/python3/dist-packages/pyparsing/core.py�__init__zcached_property.__init__Us	���D�J�Nc�n�|j|�x}|j|jj<|Sr,)r-�__dict__�__name__)r.�instance�owner�rets    r0�__get__zcached_property.__get__Xs/��;?�:�:�h�;O�O�C�(�#�#�D�J�J�$7�$7�8��Jr2r,)r5�
__module__�__qualname__r1r9�r2r0r)r)Ts��	�	r2r)c��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)r5r:r;�__doc__�
_type_desc�collect_all_And_tokens�locals�
startswith�
_all_names�split�_fixed_names)�.0�__s00r0r>r>]sH��
�!�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_debugNc�H�|jD]}|j|��yr,)�_warning_names�enable)�cls�names  r0�enable_all_warningsz__diag__.enable_all_warnings�s#���&�&�	�D��J�J�t��	r2��returnN)r5r:r;rB�)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_expressionsrDrErFrQ�_debug_names�classmethodrU)rIrJrTs000r0rLrLts����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�BrLc�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�r'����N)r5r:r;rArXrYrZr[r\r]r^r_r<r2r0rcrc�s9���.12�-�01�-�%&�"�()�%�$%�!�,-�)�/0�,�()�%r2rc�	diag_enumrWc�B�tj|j�y)zO
    Enable a global pyparsing diagnostic flag (see :class:`Diagnostics`).
    N)rLrRrT�ris r0�enable_diagrl�s��
�O�O�I�N�N�#r2c�B�tj|j�y)zP
    Disable a global pyparsing diagnostic flag (see :class:`Diagnostics`).
    N)rL�disablerTrks r0�disable_diagro�s��
���Y�^�^�$r2c�,�tj�y)zU
    Enable all global pyparsing diagnostic warnings (see :class:`Diagnostics`).
    N)rLrUr<r2r0rUrU�s��
� � �"r2�cmd_line_warn_options�warn_env_varc��t|�}|D]s}|dzjd�dd\}}}}}|j�jd�s|s|s|r|dk(rd}�M|j�jd�s�m|dvs�rd}�u|S)	Nz::::�:rf�i�	pyparsingT)rv�F)�boolrG�lowerrE)	rqrrrR�warn_opt�w_action�	w_message�
w_category�w_module�w_lines	         r0�_should_enable_warningsr��s����,�
�F�)�	��=E��=N�<U�<U��=
�
�1�=�9��)�Z��6��~�~��*�*�3�/��j�H��[�9P��F�
�^�^�
�
(�
(��
-�(�>O�2O��F�	��Mr2�PYPARSINGENABLEALLWARNINGS�
ParserElement�
0123456789�ABCDEFabcdefrw�_trim_arity_call_linec�&�������tvr�fd�Sd�d�d}txstjd��datdtd|zf������fd	�}t	�d
t	�d�j
�}||_�j|_|S)zAdecorator to trim function calls to match the arity of the targetc����|�Sr,r<)�s�l�tr/s   �r0�<lambda>z_trim_arity.<locals>.<lambda>s���t�A�w�r2rFrhrd��limit���rc����		�|�	d�}d�|S#t$rR}�r�|j}tj|d��}|d}|ddgddd�k(}~|r�	�
kr
�	dz
�	Yd}~�c�d}~wwxYw)NrTrdr�r�)�	TypeError�
__traceback__�	traceback�
extract_tb)�argsr8�te�tb�frames�
frame_summary�trim_arity_type_error�found_arityr/r��	max_limit�pa_call_line_synths       �����r0�wrapperz_trim_arity.<locals>.wrapper!s�����
��D���L�)��"���
���
����)�)�B�&�1�1�"�A�>�F�$*�2�J�M�&�r��*�+�B�/���3�7I�I�*��,� �9�,�!�Q�J�E�$���%
�s��	A+�AA&�%A&�&A+r5�	__class__)�_single_arg_builtinsr�r��
extract_stack�getattrr5rA)r/r��	LINE_DIFFr��	func_namer�r�r�s``   @@@r0�_trim_arityr�
s�����#�#�&�&�
�E��K��I�3�Z�i�6M�6M�TU�6V�WY�6Z��/��2�4I�!�4L�y�4X�Y����<��j�'�$��*D�*M�*M�N�I� �G���l�l�G�O��Nr2�fn�message�fatalc�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,)rx)r�r�r��exc_typer��msgs   ���r0�paz%condition_as_parse_action.<locals>.paZs'����B�q�!�Q�K� ��1�a��%�%�!r2)�ParseFatalException�ParseExceptionr�r)r�r�r�r�r�r�s`   @@r0�condition_as_parse_actionr�FsB��� �(�'�.M�C�&+�"��H�	�R��B�
�2�Y�&��&��Ir2�instring�loc�expr�	cache_hitc��|rdnd}t|�d|�d|�dt||��dt||��dt||��dd	t||�d
z
z�d��y)Nr"rw�Match z at loc �(�,z)
  z
  � r�^)�print�lineno�col�line)r�r�r�r��
cache_hit_strs     r0�_default_start_debug_actionr�bs{��%�C�"�M�	��o�V�D�6��#��a��s�H�8M�7N�a�PS�TW�Ya�Pb�Oc�d��c�8�$�%�&���C��*�Q�.�/�0��
3�r2�startloc�endloc�toksc�R�|rdnd}t|�d|�d|j����y)Nr"rwzMatched z -> )r��as_list)r�r�r�r�r�r�r�s       r0�_default_success_debug_actionr�os-��%�C�"�M�	�]�O�8�D�6��d�l�l�n�-=�
>�?r2�excc	�b�|rdnd}t|�d|�dt|�j�d|���y)Nr"rwr�z	 failed, z	 raised: )r��typer5)r�r�r�r�r�r�s      r0�_default_exception_debug_actionr�{s7��%�C�"�M�	�]�O�6�$��y��c��1C�1C�0D�I�c�U�
S�Tr2c��y)zG'Do-nothing' debug action, to suppress debugging output during parsing.Nr<)r�s r0�null_debug_actionr����r2c'�J
�eZdZUdZdZeed<dZeed<dZ	e
ed<eded	dfd
��Zede
d	dfd��Z
ed
��ZGd�de�Zd�defd�Zded	dfd�Zd�Zd�d�Z	d�dd�dededed	dfd�Zd�d�Zd�ded	dfd�Zded	dfd �Zded	dfd!�Zded	dfd"�Zd#ed	dfd$�Z d%ed&e!d	e!fd'�Z"d%ed&e!d	e!fd(�Z#d�d)�Z$d*�Z%	d�d	e&e!e'ffd+�Z(ddd,�d%ed&e!d-ed.ed	e!f
d/�Z)d�d%ed&e!d.ed	efd0�Z*e+�Z,iZ-e.j^e&e!d1efe&e!e0e'e1fffed2<Gd3�d4e2�Z3e3�Z4e+�Z5d5d5gZ6	d�d	e&e!e'ffd6�Z7e(Z8ed�d7��Z9dZ:dZ;ed�d8��Z<e	d�dd9�d:e.jze!d	dfd;��Z>e	d�dd9�d:e0e!dfd<ed	dfd=��Z?	d�dd>�d%ed?ed@ed	e'fdA�Z@eAdfdeAdB�d%edCe!dDedEedFe!d	eBe&e'e!e!fddffdG�ZCddH�d%edEed	efdI�ZDeAfdeAdB�d%edCe!dEedFe!d	e'f
dJ�ZEeAdfddK�d%edLe!dMed	eBeddffdN�ZFd�dO�ZGd�dP�ZHd�dQ�ZId�dR�ZJd�dS�ZKd�dT�ZLd�dU�ZMd�dV�ZNd�dW�ZOd�dX�ZPd�dY�ZQd�dZ�ZRd�d[�ZSdZTd\�ZUd�de.jzed	dfd]�ZVd�d^�ZWd�d_ed	dfd`�ZXd�d_ed	dfda�ZY	d�de0eZeefdbed	dfdc�Z[d�dd�Z\d�de�Z]dfe^dge_dhe`d	dfdi�Zad�djedked	dfdl�Zbecd	efdm��Zdeed	efdn��Zfded	dfdo�Zgecd	efdp��Zhd	efdq�Zid	efdr�Zjd�ds�Zkd	eldfdt�Zmdu�Znd�d�dv�Zo		d�dd>�dwe0eepeqfdxed?ed@ed	e'f
dy�Zrdz�Zsd{�Zt	d�dd>�d|ed?ed@ed	efd}�Zu								d�dddddd~�de0eelefd?ed�e.jze0defd�ed�ed�ed�e.jzevee'gefd�e.jzeqd�ed@ed�ed�ed�ed�e.jzevee'gefd	e&eele&ee0e'e1ffffd��Zw				d�d�e0eqepefd�e!d�ed�ed�ed	dfd��Zxeeye
�d����Zzeeye�d����Z{eye�d���Z|eye�d���Z}eye�d���Z~eye�d���Zeye�d���Z�eye �d���Z�eye)�d���Z�eeye>�d����Z�eeye?�d����Z�eye@�d���Z�eyeC�d���Z�eyeD�d���Z�eyeE�d���Z�eyeX�d���Z�eyeY�d���Z�eye[�d���Z�eye\�d���Z�eyea�d���Z�eyeb�d���Z�eyeg�d���Z�eyer�d���Z�eyew�d���Z�e*Z�e9Z�edZ�y)�r�z)Abstract base level parser element class.z 
	
�DEFAULT_WHITE_CHARSF�verbose_stacktraceN�_literalStringClass�charsrWc�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)r�r��_builtin_exprs�copyDefaultWhiteChars�set�
whiteChars)r�r�s  r0�set_default_whitespace_charsz*ParserElement.set_default_whitespace_chars�s1��-2�
�)�#�	-�D��)�)�"%�e�*���	-r2rSc��|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)r�r�)rSs r0�inline_literals_usingz#ParserElement.inline_literals_using�s��(-0�
�)r2c+�<��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,r<)rI�obj�class_kwargsrSs  ��r0�	<genexpr>z+ParserElement.using_each.<locals>.<genexpr>�s�����<��C��,�|�,�<�s�Nr<)rS�seqr�s` `r0�
using_eachzParserElement.using_each�s�����=��<�<�<�s���c�z�eZdZUejeed<ejeed<ejeed<y)�ParserElement.DebugActions�	debug_try�debug_match�
debug_failN)	r5r:r;�typing�Optional�DebugStartAction�__annotations__�DebugSuccessAction�DebugExceptionActionr<r2r0�DebugActionsr��s2���?�?�#3�4�4��_�_�%7�8�8��O�O�$8�9�9r2r��savelistc��t�|_d|_d|_d|_d|_||_d|_ttj�|_d|_d|_
d|_t�|_d|_d|_d|_d|_d|_|j+ddd�|_d|_d|_g|_y)NTFrw)�list�parseAction�
failAction�
customName�_defaultName�resultsName�
saveAsList�skipWhitespacer�r�r�r�r��mayReturnEmpty�keepTabs�ignoreExprs�debug�streamlined�
mayIndexError�errmsg�modalResultsr��debugActions�callPreparse�
callDuringTry�suppress_warnings_)r.r�s  r0r1zParserElement.__init__�s���.2�f���<@���#���26��� $���"���"����m�?�?�@���%)��"�#�����
�26�&�����
� ���!������ ��� �-�-�d�D�$�?��� ���"���57��r2�warning_typec�<�|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.rs  r0�suppress_warningzParserElement.suppress_warning�s��	
���&�&�|�4��r2c#��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    r0�	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�r�r�r�)r.�cpys  r0rzParserElement.copy
sU��,�i�i��o���*�*�1�-����*�*�1�-����%�%� ��!B�!B�C�C�N��
r2)�listAllMatchesrT�list_all_matchesrc�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::

            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.rTrrs    r0�set_results_namezParserElement.set_results_name's"��<(�;�+;���#�#�D�.�9�9r2c�|�|�|S|j�}|jd�r|dd}d}||_||_|S)Nr"r�T)r�endswithr�r�)r.rTr�newselfs    r0rzParserElement._setResultsNameHsK���<��K��)�)�+���=�=������9�D�!�N�"���#1�1����r2T�
break_flagc���|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�B��ddl}|j��||||�S�Nr)�pdb�	set_trace)r�r��	doActions�callPreParser�_parseMethods     �r0�breakerz(ParserElement.set_break.<locals>.breaker\s"�����
�
��#�H�c�9�l�K�Kr2�_originalParseMethod�TT)�_parser%�hasattr)r.rr$r#s   @r0�	set_breakzParserElement.set_breakSsV�����;�;�L�
L�,8�G�(�!�D�K����t�{�{�$:�;�"�k�k�>�>����r2�fnsc��t|�dgk(r	g|_|Std�|D��std��|D�cgc]
}t	|���c}|_|jd|jdd��|_|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)rIr�s  r0r�z1ParserElement.set_parse_action.<locals>.<genexpr>�s����2��x��|�2���zparse actions must be callable�call_during_tryrF)r�r��allr�r��getr�r.r*�kwargsr�s    r0�set_parse_actionzParserElement.set_parse_actionjs���V��9����!�D����
�2�c�2�2�� @�A�A�:=�>�B��B��>�D��!'���!�6�:�:�o�u�#E�"�D�����	 ?s�A=c���|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`.
        r/rF)r�r�rr1r2s    r0�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�r/r)r�rr��strr1rxrr2s    r0�
add_conditionzParserElement.add_condition�s���.�	�B����#�#�)����
�
�9� 5�6��v�z�z�'�5�9�:��
�	�"�/�/�
�6�:�:��v�z�z�/�5�A�4
����r2r�c��||_|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  r0�set_fail_actionzParserElement.set_fail_action�s������r2r�r�c���|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	         r0�_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�rDr��lenr�)r.r�r��instrlen�white_charss     r0�preParsezParserElement.preParsesn������&�&�x��5�C�����8�}�H��/�/�K���.�X�c�]�k�%A��q�����.�X�c�]�k�%A��
r2c�
�|gfSr,r<�r.r�r�r!s    r0�	parseImplzParserElement.parseImpl"����B�w�r2c��|Sr,r<�r.r�r��	tokenlists    r0�	postParsezParserElement.postParse%s���r2c
��d\}}}|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)N�rrrdF)�asList�modalz exception raised in parse action)r�rGr�rrJr�r�r�rM�
IndexErrorr�r��	Exceptionr�rRr#r�r�r�r�r�
isinstancer�r�)r.r�r�r!r"�TRY�MATCH�FAIL�	debugging�len_instring�pre_loc�tokens_start�tokens�err�
ret_tokensr��parse_action_excr�s                  r0�
_parseNoCachezParserElement._parseNoCache)s���#���U�D��J�J�	��8�}������
��D�$5�$5�"�m�m�H�c�:�G�!�G�&���$�$�.�.��%�%�/�/��,��e�T��%�%��L�)@�X�&*�n�n�X�w�	�&R���V�#'�.�.��7�I�"N�K�C����� 1� 1��-�-��#�6����"�L��!�!�W��%<�T�"&�.�.��7�I�"N�K�C��#�n�n�X�w�	�J���V�����#�v�6��!��D�$�$�T�_�_�D�DU�DU�
�
�����d�.@�.@���"�.�.���<�%'��,�
�%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*J;�J�.J;�=L"�M&�
M�!M&�$M&�)AM&�
N-�"J8�8J;�;	L�AL�L�""M�	M#�M�M#�#M&�&	N*�/6N%�%N*�-	O	�6O�O	)�raise_fatal�
do_actionsrfrgc��	|j|||��dS#t$r|r�t|||j|��wxYw)N�r!r)r'r�r�r�)r.r�r�rfrgs     r0�	try_parsezParserElement.try_parse�sN��	C��;�;�x��
�;�C�A�F�F��"�	C��� ��3����T�B�B�	C�s��%>c�X�	|j|||��y#ttf$rYywxYw)N�rgTF)rjr�rW)r.r�r�rgs    r0�can_parse_nextzParserElement.can_parse_next�s7��	��N�N�8�S�Z�N�@����
�+�	��	�s��)�)�Forward�recursion_memosc�(�eZdZUdZeed<d�Zd�Zy)�ParserElement._CacheTypez-
        class to help type checking
        �not_in_cachec��yr,r<�r.r�s  r0r1zParserElement._CacheType.get����r2c��yr,r<rts  r0r�zParserElement._CacheType.set�rur2N)r5r:r;rArxr�r1r�r<r2r0�
_CacheTyperq�s��	���	�	r2rwrc	���d\}}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)rrrTrrT)r�rd)r��packrat_cache_lock�
packrat_cacher1rr�packrat_cache_statsrer�r�ParseBaseExceptionr�r�r�r�r�r�rYrXr�rr�intr#r�)r.r�r�r!r"�HIT�MISSrZr[r\�lookup�cache�value�pe�loc_�resultr�s                 r0�_parseCachezParserElement._parseCache�sm���	��T�"���U�D���#�|�Y�?��
�
-�
-�)	$�!�/�/�E��I�I�f�%�E���*�*�*��1�1�$�7�1�<�7�!� �.�.�x��i��V�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%�/G;�*I%�7=I%�5H6�2I%� I�'A%I%�
!I�.I%�;	H3�*H.�.H3�3I%�6	I�?I%�I�I%�	I�I%�I�I%�	I"�I%�!I"�"I%�%I.c���tjj�dgttj�ztjddtj
j�yr)r�rz�clearrGr{ror<r2r0�reset_cachezParserElement.reset_cache�sO���#�#�)�)�+�01�s�S��-�-�6
�0
�
�)�)�!�,�	�%�%�+�+�-r2c��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)r�r��_left_recursion_enabled�_packratEnabledrer'r<r2r0�disable_memoizationz!ParserElement.disable_memoizations.��	�!�!�#�05�
�-�(-�
�%�,�:�:�
�r2)�force�cache_size_limitc��|rtj�ntjrtd��|�t	�t_dt_y|dkDr!t
|��t_dt_ytd|z��)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)�capacityzMemo size of %sT)	r�r�r��RuntimeError�_UnboundedMemoro�_LRUMemo�NotImplementedErrorr��r�r�s  r0�enable_left_recursionz#ParserElement.enable_left_recursionsz��H��-�-�/�
�
*�
*��Q�R�R��#�,:�,<�M�)�
15�
�-�	��
!�,4�>N�,O�M�)�15�
�-�&�&7�:J�&J�K�Kr2r�c�&�|rtj�ntjrtd��tjsOdt_|�t�t_nt|�t_tjt_	yy)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�TN)
r�r�r�r�r�rrzrr�r'r�s  r0�enable_packratzParserElement.enable_packrat>sl��D��-�-�/�
�
2�
2��Q�R�R��,�,�,0�M�)��'�.=�.?�
�+�.8�9I�.J�
�+�#0�#<�#<�M� �
-r2)�parseAll�	parse_allr�c���|xs|}tj�|js|j�|jD]}|j��|j
s|j
�}	|j|d�\}}|r9|j||�}t�t�z}|j||�|S#t$r'}tjr�|jd��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)
        rN)r�r�r��
streamliner�r��
expandtabsr'rJ�Empty�	StringEndr|r��with_traceback)	r.r�r�r�r?r�ra�ser�s	         r0�parse_stringzParserElement.parse_stringls���Z�(����!�!�#�����O�O���!�!�	�A�
�L�L�N�	��}�}��*�*�,�H�
	��+�+�h��2�K�C����m�m�H�c�2���W�y�{�*���	�	�(�C�(��M��"�	/��/�/���(�(��.�.��	/�s�5AC�	C7�"C2�2C7)r��
maxMatches�max_matches�overlapr�r�c#��K�t||�}|js|j�|jD]}|j��|jst|�j
�}t|�}d}|j}	|j}
tj�d}	||kr}||krw	|	||�}|
||d��\}
}|
|kDrG|dz
}|rt|j�||
d��|||
f��|r|	||�}||kDr|
}n|dz
}n	|
}n|dz}	||kr||kr�uyyyy#t$rdz}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)ra�start�endN)�minr�r�r�r�r8r�rGrJr'r��
resetCacher�rUr�r|r�r�)r.r�r�r�r�r�r?rHr��
preparseFn�parseFn�matches�preloc�nextLocra�nextlocr�s                 r0�scan_stringzParserElement.scan_string�s�����N��[�1�
�����O�O���!�!�	�A�
�L�L�N�	��}�}��8�}�/�/�1�H��x�=�����]�]�
��+�+��� � �"���$	/���/�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"�	/��/�/���(�(��.�.��	/�sO�B*E7�-
E�8D0�AE�,E7�0E�>E�E�E�	E4�
"E/�/E4�4E7�r�c�x�g}d}d|_	|j||��D]�\}}}|j|||�|rgt|t�r||j�z
}nCt|t�r"t|t�s|j|�n|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�Nrw)r�r�rrYr#r�rr&r
�joinrr8r|r�r�r�)
r.r�r��out�lastEr�r�r?�or�s
          r0�transform_stringzParserElement.transform_strings"��(������
�	/��+�+�H�E�+�B�	
���1�a��
�
�8�E�!�,�-��!�!�\�2��q�y�y�{�*��#�A�x�0��A�x�9P��
�
�1�
��
�
�1�
���	
�
�J�J�x���'�(�!�'��Q�1�'�C�'��7�7�H�S�M�:�q�C��F�:�;�;��(��:��!�	/��/�/���(�(��.�.��	/�s<�B3D	�C?�C?�D	�&D�8D	�?
D	�		D9�"D4�4D9c
��t||�}	t|j|||��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']
        r�N)r�r#r�r|r�r�r�)	r.r�r�r�r�r�r�r?r�s	         r0�
search_stringzParserElement.search_string:s}��8��[�1�
�		/��"&�"2�"2�8�Z�u�"2�"U�V�V�w�q�!�Q��V��
��V��!�	/��/�/���(�(��.�.��	/�s'�A�
A�A�A�	A8�"A3�3A8)�includeSeparators�maxsplit�include_separatorsc#�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�r�r�r��lastr�r�r?s	         r0rGzParserElement.splitbsj����..�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�_PendingSkiprYr&r�r��NotImplemented�And�r.�others  r0�__add__zParserElement.__add__�sP��6�H����%�%��e�X�&��,�,�U�3�E��%��/�!�!��D�%�=�!�!r2c��|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��SkipTorYr&r�r�r�r�s  r0�__radd__zParserElement.__radd__�sV���H���6�$�<��,�t�3�3��e�X�&��,�,�U�3�E��%��/�!�!��t�|�r2c��t|t�r|j|�}t|t�stS|t
j
�z|zS)zX
        Implementation of ``-`` operator, returns :class:`And` with error stop
        )rYr&r�r�r�r��
_ErrorStopr�s  r0�__sub__zParserElement.__sub__�sE���e�X�&��,�,�U�3�E��%��/�!�!��c�n�n�&�&��.�.r2c�z�t|t�r|j|�}t|t�stS||z
S)zd
        Implementation of ``-`` operator when left operand is not a :class:`ParserElement`
        �rYr&r�r�r�r�s  r0�__rsub__zParserElement.__rsub__��8���e�X�&��,�,�U�3�E��%��/�!�!��t�|�r2c�H���|turd}n+t|t�r|ddtfk(rd|ddzdzdd}t|t�r|d}}n�t|t�r�td�|D��}|d	zdd}|d�d|df}t|dt�r?|d�:|ddk(rt	��S|ddk(rt��S�|dzt	��zSt|dt�rt|dt�r|\}}||z}ntStS|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,rdrc3�4K�|]}|tur|nd���y�wr,)r�)rIr�s  r0r�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��SrF)�Opt)�n�makeOptionalListr.s ��r0r�z/ParserElement.__mul__.<locals>.makeOptionalLists.����q�5��t�&6�q�1�u�&=�=�>�>��t�9�$r2)	r�rY�tupler}�
ZeroOrMore�	OneOrMorer��
ValueErrorr�)r.r��minElements�optElementsr8r�s`    @r0�__mul__zParserElement.__mul__�s���*�H���E�
��u�
%�%���)��{�*B��E�!�"�I�%��/��!�4�E��e�S�!�',�a��K�
��u�
%��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�&�;�.�/���
r2c�$�|j|�Sr,)r�r�s  r0�__rmul__zParserElement.__rmul__s���|�|�E�"�"r2c���|tur
t|d��St|t�r!|dk(rt	|�S|j|�}t|t�stSt||g�S)zP
        Implementation of ``|`` operator - returns :class:`MatchFirst`
        T)�	must_skiprw)	r�r�rYr&r�r�r�r��
MatchFirstr�s  r0�__or__zParserElement.__or__sc���H�����5�5��e�X�&���{��4�y� ��,�,�U�3�E��%��/�!�!��4��-�(�(r2c�z�t|t�r|j|�}t|t�stS||zS)zd
        Implementation of ``|`` operator when left operand is not a :class:`ParserElement`
        r�r�s  r0�__ror__zParserElement.__ror__)r�r2c��t|t�r|j|�}t|t�stSt||g�S)zH
        Implementation of ``^`` operator - returns :class:`Or`
        )rYr&r�r�r��Orr�s  r0�__xor__zParserElement.__xor__3s=���e�X�&��,�,�U�3�E��%��/�!�!��4��-� � r2c�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  r0�__rxor__zParserElement.__rxor__=r�r2c��t|t�r|j|�}t|t�stSt||g�S)zJ
        Implementation of ``&`` operator - returns :class:`Each`
        )rYr&r�r�r��Eachr�s  r0�__and__zParserElement.__and__Gs=���e�X�&��,�,�U�3�E��%��/�!�!��T�5�M�"�"r2c�z�t|t�r|j|�}t|t�stS||zS)zd
        Implementation of ``&`` operator when left operand is not a :class:`ParserElement`
        r�r�s  r0�__rand__zParserElement.__rand__Qr�r2c��t|�S)zL
        Implementation of ``~`` operator - returns :class:`NotAny`
        )�NotAny�r.s r0�
__invert__zParserElement.__invert__[s���d�|�r2c�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�rrrdz'only 1 or 2 index arguments supported (rfz... [�]rw�))�NoMatchrY�slicer��stopr�r&�iterr�rGr�r�_MultipleMatch�stopOn)r.�key�stop_on_defined�stop_onr8s     r0�__getitem__zParserElement.__getitem__es=��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.rTs  r0�__call__zParserElement.__call__�s'�����'�'��-�-��9�9�;�r2c��t|�S)z�
        Suppresses the output of this :class:`ParserElement`; useful to keep punctuation from
        cluttering up returned output.
        )�Suppressr�s r0�suppresszParserElement.suppress�s��
��~�r2�	recursivec��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.r
s  r0�ignore_whitespacezParserElement.ignore_whitespace�s��#����r2c��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  r0�leave_whitespacezParserElement.leave_whitespace�s��$����r2�
copy_defaultsc�B�d|_t|�|_||_|S)z8
        Overrides the default whitespace chars
        T)r�r�r�r�)r.r�rs   r0�set_whitespace_charsz"ParserElement.set_whitespace_chars�s$��#����e�*���%2��"��r2c��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�r�s r0�parse_with_tabszParserElement.parse_with_tabs�s����
��r2c��ddl}t|t�rt|�}t|t�r+||jvr|jj|�|S|jjt|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)[1, ...]
            patt.parse_string('ablaj /* comment */ lskjd')
            # -> ['ablaj']

            patt.ignore(c_style_comment)
            patt.parse_string('ablaj /* comment */ lskjd')
            # -> ['ablaj', 'lskjd']
        rN)r�rYr&rr�rr)r.r�r�s   r0�ignorezParserElement.ignore�ss�� 	��e�X�&��U�O�E��e�X�&��D�,�,�,�� � �'�'��.���
���#�#�H�U�Z�Z�\�$:�;��r2�start_action�success_action�exception_actionc�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.rrrs    r0�set_debug_actionszParserElement.set_debug_actionss@��$!�-�-��7�7��;�;��?� ?�
���
��
��r2�flagrc��|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)r�	set_debugrr�r�r�r�)r.r rr�s    r0r"zParserElement.set_debugsb��L����(�
4�����t�U��3�
4��K���"�"�+�-�/�
����D�J��r2c�\�|j�|j�|_|jSr,)r��_generateDefaultNamer�s r0�default_namezParserElement.default_namePs+�����$� $� 9� 9� ;�D��� � � r2c��y)zg
        Child classes must define this method, which defines how the ``default_name`` is set.
        Nr<r�s r0r$z"ParserElement._generateDefaultNameVr�r2c�|�||_d|jz|_tjr|j�|S)a^
        Define name for this expression, makes debugging and exception messages clearer.

        Example::

            Word(nums).parse_string("ABC")  # -> Exception: Expected W:(0-9) (at char 0), (line:1, col:1)
            Word(nums).set_name("integer").parse_string("ABC")  # -> Exception: Expected integer (at char 0), (line:1, col:1)
        �	Expected )r�rTr�rLr_r"rs  r0�set_namezParserElement.set_name\s3�����!�D�I�I�-����5�5��N�N���r2c�J�|j�|jS|jSr,)r�r%r�s r0rTzParserElement.nameks"��#'�/�/�"=�t���T�4�CT�CT�Tr2c��|jSr,�rTr�s r0�__str__zParserElement.__str__ps���y�y�r2c��t|�Sr,�r8r�s r0�__repr__zParserElement.__repr__ss���4�y�r2c�"�d|_d|_|S�NT)r�r�r�s r0r�zParserElement.streamlinevs����� ����r2c��gSr,r<r�s r0rzParserElement.recurse{����	r2c�b�|dd|gz}|j�D]}|j|��yr,)r�_checkRecursion�r.�parseElementList�subRecCheckListr?s    r0r6zParserElement._checkRecursion~s6��*�1�-���6������	/�A�
���o�.�	/r2c�^�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 recursionrd��
stacklevelN)�warningsrN�DeprecationWarningr6)r.�
validateTraces  r0�validatezParserElement.validate�s)��	�
�
�h���	
�
	
���R� r2�file_or_filename�encodingc��|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�rCN)r�rr�read�AttributeErrorr8�openr�r|r�r�r�)r.rBrCr�r��
file_contents�fr�s        r0�
parse_filezParserElement.parse_file�s����(�y��	)�%�{�{�6�3C�D��,�1�1�3�M�
	/��$�$�]�H�=�=���	)�%�{�{�3�0@�A���&��h�?�
)�1� !����
�
)�
)�
)��	)��"�	/��/�/���(�(��.�.��	/�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)rYr&r�r��varsr�s  r0�__eq__zParserElement.__eq__�sI���5�=��
��x�
(��<�<���<�6�6�
��}�
-���:��e��,�,�r2c��t|�Sr,)�idr�s r0�__hash__zParserElement.__hash__�s���$�x�r2�test_stringc�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")
        rNTF)r�r8r|)r.rTr�r�s    r0r�zParserElement.matches�s@��"�)�	��	����c�+�.�(��C���!�	��	�s�%�	1�1)r��fullDump�printResults�failureTestsrR�tests�comment�	full_dump�
print_results�
failure_tests�
post_parse�file�with_line_numbersrVrWrXrRc
	���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�]�}|r|j)|d�s|r'|s%|j+|	r|j-|�n|��A|s�D|rddj/|�znd	|	r|j-|�n|g}g}	|j1|j3|��}|j5||
�
�}|xr|
}|�w	|||�}|�Kt|t6�r |j+|j9��n:|j+t
|��n|j+|j9��n"|j+|j9|���	|j+d	�|r|dj/|��|j+||f����||fScc}w#t:$ra}|j+|j9|���|j+|j<�dt|�j<�d
|���Yd}~��d}~wwxYw#t>$r�}t|t@�rdnd	}|j+|jC��|j+dt
|�z�tjDr.|jGtIjJ|jL��|xr|
}|}Yd}~��[d}~wt:$r{} |j+dt| �j<�d
| ���tjDr.|jGtIjJ| jL��|xr|
}| }Yd} ~ ���d} ~ 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�
uFrwrN)�fullz	 failed: �: z(FATAL)zFAIL: zFAIL-EXCEPTION: )'�testingrbrYr&r�rr8r��strip�rstrip�
splitlines�Literalr��sys�stdout�writer6�replace_withr�
quoted_stringr�rr`r�r��lstripr�r#�dumprXr5r|r��explainr�r
r��	format_tbr�)!r.rYr�rZr[r\r]r^r_r`r�rVrWrXrRrb�
line_strip�	test_line�comment_specified�print_�
allResults�comments�success�NL�BOMr�r�r��pp_valuer?r�r�r�s!                                 r0�	run_testszParserElement.run_tests�s���b	,��)�	���)�	��#�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�����7	+�A� �W�_�_�Q��%>�(�ST����;L�N�4�4�Q�7�RS�����.6��t�y�y��*�*�B�7H��0�0��3�a��C��H�$
;��'�'�����
�6���*�*�1��*�A�� "�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�*�o7	+�r�
�"�"��UY��x%���
�
�6�;�;�H�;�#=�>��
�
�(�1�1�2�)�D��G�<L�<L�;M�R�PQ�s�S������5&�
�%/��4G�%H�	�b���
�
�2�:�:�<�(��
�
�8�c�"�g�-�.� �3�3��J�J�y�2�2�2�3C�3C�D�E�!�2�l������
��
�
�-�d�3�i�.@�.@�-A��C�5�I�J� �3�3��J�J�y�2�2�3�3D�3D�E�F�!�2�l�����
�sF�K�<3M�9A5K�	M�#AL?�?M�	Q3�BO,�,Q3�8A0Q.�.Q3�output_html�vertical�show_results_names�show_groups�embedc�f�	ddlm}m}|j�||||||��}
t
|ttf�r2t|dd��5}|j||
fd	|i|���ddd�y|j||
fd	|i|���y#t$r}	t	d�|	�d}	~	wwxYw#1swYyxYw)
ag
        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
        - ``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)r�r�r��diagram_kwargs�w�utf-8rFr�)�diagramr�r��ImportErrorrXr�rYr8rrIrn)r.r�r�r�r�r�r3r�r��ie�railroad�	diag_files            r0�create_diagramzParserElement.create_diagram�s���@	�>�	
�������1�#�!�
���k�C��;�/��k�3��9�
S�Y���� 0�� Q�� Q�&� Q�R�
S�
S�
���.�x�O�u�O��O�P��'�	��_���
��	��
S�
S�s#�B
�B'�
	B$�B�B$�'B0c��yr,r<r<r2r0�inlineLiteralsUsingz!ParserElement.inlineLiteralsUsing����"r2c��yr,r<r<r2r0�setDefaultWhitespaceCharsz'ParserElement.setDefaultWhitespaceChars�s��%(r2c��yr,r<r�s r0�setResultsNamezParserElement.setResultsName����!r2c��yr,r<r�s r0�setBreakzParserElement.setBreak����r2c��yr,r<r�s r0�setParseActionzParserElement.setParseAction�r�r2c��yr,r<r�s r0�addParseActionzParserElement.addParseAction�r�r2c��yr,r<r�s r0�addConditionzParserElement.addCondition����r2c��yr,r<r�s r0�
setFailActionzParserElement.setFailAction���� r2c��yr,r<r�s r0�tryParsezParserElement.tryParse�r�r2c��yr,r<r<r2r0�enableLeftRecursionz!ParserElement.enableLeftRecursion�r�r2c��yr,r<r<r2r0�
enablePackratzParserElement.enablePackrat�s��r2c��yr,r<r�s r0�parseStringzParserElement.parseString�s��r2c��yr,r<r�s r0�
scanStringzParserElement.scanString�s��r2c��yr,r<r�s r0�transformStringzParserElement.transformString����"r2c��yr,r<r�s r0�searchStringzParserElement.searchString�r�r2c��yr,r<r�s r0�ignoreWhitespacezParserElement.ignoreWhitespace	��� #r2c��yr,r<r�s r0�leaveWhitespacezParserElement.leaveWhitespace	r�r2c��yr,r<r�s r0�setWhitespaceCharsz ParserElement.setWhitespaceChars	s��"%r2c��yr,r<r�s r0�
parseWithTabszParserElement.parseWithTabs
	r�r2c��yr,r<r�s r0�setDebugActionszParserElement.setDebugActions
	r�r2c��yr,r<r�s r0�setDebugzParserElement.setDebug	r�r2c��yr,r<r�s r0�setNamezParserElement.setName	���r2c��yr,r<r�s r0�	parseFilezParserElement.parseFile	s��r2c��yr,r<r�s r0�runTestszParserElement.runTests	r�r2�F�rWr��Tr&rVr,)�)r�r�rWr�)TF)r�F)T�#TTFNNF)r'FFF)�r5r:r;rAr�r8r�r�rxr�r��staticmethodr�r�rar�rr�r1rcrrrrrr)�ParseActionr4r6�ParseConditionr9�ParseFailActionr;r}rDrJrMrRrr#rerjrmr�recursion_lockror��Dictr
rX�dictrwrzryr{r�r'r�r�r�r�r�r�r�r��_MAX_INTrr�r�r�rGr�r�r�r�r�r�r�r�r�r�r�r�r��__iter__rr	rrrr
rrrr�r�r�rr"�propertyr%rr$r)rTr-r0r�rrr6rArrrLrPrSr�rrr�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��canParseNextr��defaultNamer<r2r0r�r��s�
��3�(���(�$���$� $���$��-�C�-�D�-��-�(�0�4�0�D�0��0�*�	=��	=�:�z�:�
8��8�8�[��_�� �"�<38�:�SX�:��:�+/�:�LP�:�	�:�B	��D��O��.T�[�T��T�l
�[�
��
�#�.�#��#�J�/��o�� ���#��#��*
��
�3�
�3�
���
;?�d�	�s�L� �	!�d�V"� �

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

C�

�
C��s����$��SW���W�N�	��V�[�[�
�c�9�d�"�#�U�3��l�I�6M�0N�+N�%O�O����T��	�������a�&��
;?�/$�	�s�L� �	!�/$�b�F��.��.��O�#���;��;��15�-5�@E�-5� �/�/�#�.�-5�	
�-5��-5�^�-0�+=�CH�+=���T�	�*�+=�<@�+=�	
�+=��+=�\05�C�JO�C��C�(,�C�CG�C�	�C�P$��	Y/��"�Y/��Y/��Y/��	Y/��
Y/��Y/�
�5��s�C�/�0�$��<�	=�Y/�v@E�,/��,/��,/��,/�b$�&/�
�"�
&/��&/��&/�
�&/��
&/�
�&/�V!�#(�	� �
�����!�	�
�3��d�?�	#��@""�H�/��M�^#�)� �!��#����H�:�x�V�_�_�S�1��_��(��4��?��	�$�	�/�	�BG�	��3�s�8�S�=�)�	�:>�	�	�	���8�&��+��/�	�

��43�d�3�D�3�_�3�j�!�c�!��!�
��c����

�S�
�_�
��U�c�U��U�����#���
��o�.��/�
	!� ��	/��
/���T�6� 1�2�/��/��	/��
/�
�/�<��37��LP����+/��EI��	
��6�@C��"�#�JN�(,�"'�E#���!�"�IM�!E#��S�$�s�)�^�$�E#��E#�������';�!<�=�	E#�
�E#��
E#��E#��O�O�H�c�<�-@�#�-E�$F�G�E#��o�o�f�%�E#� �E#��E#��E#��E#��E#� �?�?�8�S�,�,?��,D�#E�F�!E#�"
�t�T�%��U�<��+B�%C� C�D�E�E�	F�#E#�T�#(�!��
5Q��6�4��,�-�5Q��5Q�!�	5Q�
�5Q��
5Q�
�5Q�r��+�,�"�-��"���2�3�(�4��(��&�'�!�(�!��i� ��!���&�'�!�(�!��&�'�!�(�!��m�$��%���o�&� �'� ��i� ��!����+�,�"�-��"���n�%��&����l�#��$���k�"��#���&�'�"�(�"��m�$��%���'�(�#�)�#��&�'�"�(�"��*�+�%�,�%��o�&� �'� ��'�(�"�)�"��i� ��!���h��� ���j�!��"���i� ��!��!�L��J��Kr2c�J��eZdZd	dedef�fd�
Zdefd�Zd
d�Zd�Z	d�Z
�xZS)r�r�r�c�>��t�|��||_||_yr,)�superr1�anchorr�)r.r�r�r�s   �r0r1z_PendingSkip.__init__%	s���
�������"��r2rWc�b�t|jt�z�jdd�S)Nr��...)r8r�r��replacer�s r0r$z!_PendingSkip._generateDefaultName*	s%���4�;�;���(�)�1�1�'�5�A�Ar2c�
��t|�jd�d�}�jrEd�}�fd�}�j|�j	|�z|�j	|�z|zS�j|z|zS)Nr�r�c��|jr|jj�dgk(r|d=|jdd�yy)Nrwr�_skipped)r�r��pop)r�s r0r�z'_PendingSkip.__add__.<locals>.must_skip1	s:���z�z�Q�Z�Z�%7�%7�%9�b�T�%A��!���E�E�*�d�+�&Br2c���|jj�dddgk(r0|jd�dt�j�zdz|d<yy)Nr�rwr�z	missing <�>)r�r�r��reprr�)r�r.s �r0�	show_skipz'_PendingSkip.__add__.<locals>.show_skip6	sN����:�:�%�%�'���,���4��E�E�*�%�$/�$�t�{�{�2C�$C�c�$I�A�j�M�5r2)r�r)r�r�r6)r.r��skipperr�r�s`    r0r�z_PendingSkip.__add__-	s����/�&��-�(�(��/��<���>�>�
,�

J����g�i�8�8��C�C��)�,�,�Y�7�8���
�
�{�{�W�$�u�,�,r2c��|jSr,)r�r�s r0r0z_PendingSkip.__repr__B	s�����r2c��td��)NzBuse of `...` expression without following SkipTo target expression)rXrts  r0rMz_PendingSkip.parseImplE	s���P�
�	
r2r�r�)r5r:r;r�rxr1r8r$r�r0rM�
__classcell__�r�s@r0r�r�"	s3���#�]�#�t�#�
B�c�B�-�* �
r2r�c�.��eZdZdZ�fd�Zdefd�Z�xZS)�TokenzYAbstract :class:`ParserElement` subclass, for defining atomic
    matching patterns.
    c�&��t�|�d��y)NF�r��r�r1�r.r�s �r0r1zToken.__init__P	s���
���%��(r2rWc�,�t|�jSr,)r�r5r�s r0r$zToken._generateDefaultNameS	s���D�z�"�"�"r2)r5r:r;rAr1r8r$r�r�s@r0r�r�K	s����)�#�c�#r2r�c�*��eZdZdZ�fd�Zdd�Z�xZS)r�z(
    A token that will never match.
    c�L��t�|��d|_d|_d|_y)NTFzUnmatchable token)r�r1r�r�r�r�s �r0r1zNoMatch.__init__\	s%���
����"���"���)��r2c�2�t|||j|��r,)r�r�rLs    r0rMzNoMatch.parseImplb	s���X�s�D�K�K��>�>r2r��r5r:r;rAr1rMr�r�s@r0r�r�W	s����*�?r2r�c�j��eZdZdZddd�dedef�fd�Zd�Zddd�dedef�fd�Zd	efd
�Zd
d�Z	�xZ
S)rka�
    Token to exactly match a specified string.

    Example::

        Literal('blah').parse_string('blah')  # -> ['blah']
        Literal('blah').parse_string('blahfooblah')  # -> ['blah']
        Literal('blah').parse_string('bla')  # -> Exception: Expected "blah"

    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`.
    rw��matchString�match_stringr�c���|tur<|xs|}|st�|�	t�St	|�dk(rt�|�	t
�St�|�	|�SrF)rkr��__new__r�rG�_SingleCharLiteral)rSr�r�r�s   �r0r�zLiteral.__new__v	sT����'�>�&�6�,�L���w��u�-�-��<� �A�%��w��'9�:�:��w��s�#�#r2c��|jfSr,)�matchr�s r0�__getnewargs__zLiteral.__getnewargs__�	s���
�
�}�r2c���t�|��|xs|}||_t|�|_|dd|_d|jz|_d|_d|_	y)Nrr(F)
r�r1rrG�matchLen�firstMatchCharrTr�r�r��r.r�r�r�s   �r0r1zLiteral.__init__�	sZ���
����"�2�l��!��
��L�)��
�*�2�A�.���!�D�I�I�-���#���"��r2rWc�,�t|j�Sr,�r�rr�s r0r$zLiteral._generateDefaultName�	����D�J�J��r2c���|||jk(r7|j|j|�r||jz|jfSt	|||j
|��r,)rrErrr�r�rLs    r0rMzLiteral.parseImpl�	sY���C�=�D�/�/�/�H�4G�4G��J�J��5
�����&��
�
�2�2��X�s�D�K�K��>�>r2�rwr�)r5r:r;rAr8r�rr1r$rMr�r�s@r0rkrkf	sR���
�
$�2�
$�3�
$�S�
$��#�R�#�S�#�s�#� �c� �?r2rkc�>��eZdZdZddd��fd�Zdefd�Zd	d�Z�xZS)
r�z,
    An empty token, will always match.
    rwr�c�@��t�|�d�d|_d|_y)NrwTF�r�r1r�r�rs   �r0r1zEmpty.__init__�	s ���
�����"���"��r2rWc��y)Nr�r<r�s r0r$zEmpty._generateDefaultName�	s��r2c�
�|gfSr,r<rLs    r0rMzEmpty.parseImpl�	rNr2rr�)	r5r:r;rAr1r8r$rMr�r�s@r0r�r��	s%����#�r�#�
�c��r2r�c��eZdZdd�Zy)r�c�x�|||jk(r|dz|jfSt|||j|��rF)rrr�r�rLs    r0rMz_SingleCharLiteral.parseImpl�	s<���C�=�D�/�/�/���7�D�J�J�&�&��X�s�D�K�K��>�>r2Nr�)r5r:r;rMr<r2r0r�r��	s��?r2r�c
���eZdZdZedzZ			dddd�dedejede	d	ed
ejef
�fd�Z
defd
�Zdd�Ze
dd��ZeZ�xZS)�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_$rwN�r��
identCharsr��ident_chars�caselessr�rc���t�|��|xs|}|�tj}|xs|}||_t|�|_	|d|_dt|�j�d|j��|_
d|_d|_||_|r%|j#�|_|j#�}t'|�|_y#t$rtd��wxYw)Nrz2null string passed to Keyword; use Empty() insteadr(r�F)r�r1r�DEFAULT_KEYWORD_CHARSrrGrrrWr�r�r5rTr�r�r�r�upper�
caselessmatchr�r)r.r�rrr�rr�s      �r0r1zKeyword.__init__�	s����	�����.�;�
��� �6�6�J�"�2�l��!��
��L�)��
�	S�".�q�/�D��"�$�t�*�"5�"5�!6�a��	�	�{�C���#���"��� ��
��!-�!3�!3�!5�D��#�)�)�+�J��j�/�����	S��Q�R�R�	S�s�
C�CrWc�,�t|j�Sr,rr�s r0r$zKeyword._generateDefaultName�	r	r2c��|j}|}|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||||��)Nrrz/, was immediately followed by keyword characterz7, keyword was immediately preceded by keyword characterz7, keyword was immediately followed by keyword character)r�rrrrrrGrrrEr�)r.r�r�r!r��errlocs      r0rMzKeyword.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�>�>��"S�S��!$�t�}�}�!4���W�W�F� �1�W�F�
��
��!4�!4�4��M�M�Q�&��&�&�t�z�z�3�7��!�8�x��a��0����G��s�8�}�t�}�}�<�<�#�C�$�-�-�$7�8����O�"�T�]�]�2�D�J�J�>�>��U���"%�t�}�}�!4���W�W�F� �1�W�F��X�v�v�t�<�<r2c��|t_y)zX
        Overrides the default characters used by :class:`Keyword` expressions.
        N)rr)r�s r0�set_default_keyword_charsz!Keyword.set_default_keyword_chars"
s��
).��%r2)rwNFr�rV)r5r:r;rA�	alphanumsrr8r�r�rxr1r$rMr�r!�setDefaultKeywordCharsr�r�s@r0rr�	s�����4&��,���,0��	*��+/�*��*��_�_�S�)�*��	*��
*��O�O�C�(�*�: �c� �-=�^�.��.�7�r2rc�<��eZdZdZddd�dedef�fd�Zd	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`.)
    rwr�r�r�c���|xs|}t�|�|j��||_d|jz|_y)Nr()r�r1r�returnStringrTr�rs   �r0r1zCaselessLiteral.__init__:
s;���"�2�l��
����+�+�-�.�(���!�D�I�I�-��r2c���||||jzj�|jk(r||jz|jfSt	|||j
|��r,)rrrr'r�r�rLs    r0rMzCaselessLiteral.parseImplA
sV���C�#��
�
�-�.�4�4�6�$�*�*�D�����&��(9�(9�9�9��X�s�D�K�K��>�>r2rr�)r5r:r;rAr8r1rMr�r�s@r0r%r%,
s'����.�R�.�S�.�s�.�?r2r%c�v��eZdZdZ		d
ddd�dedejededejef�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`.)
    rwNrr�rr�rc�B��|xs|}|xs|}t�|�||d��y)NT)rr�)r.r�rr�rr�s     �r0r1zCaselessKeyword.__init__S
s-��� �.�;�
�"�2�l��
����z�D��Ar2)rwN)	r5r:r;rAr8r�r�r1r�r�s@r0r*r*G
sf���	��,0�
B�
�+/�
B��
B��_�_�S�)�
B�
�
B��O�O�C�(�
B�
Br2r*c�j��eZdZdZ	dddd�dedejedef�fd�Zd	efd
�Z	d
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)�
maxMismatchesrr��max_mismatchesr.c���|�|n|}t�|��||_||_d|j�d|j�d�|_||_d|_d|_y)Nr(z
 (with up to z mismatches)F)r�r1r�r.r�rr�r�)r.r�r/r.rr�s     �r0r1zCloseMatch.__init__�
sh���+9�*D��-�
�
����(���*���!�$�"3�"3�!6�m�D�DV�DV�CW�Wc�d��� ��
�"���#��r2rWc�J�t|�j�d|j��S)Nrt)r�r5r�r�s r0r$zCloseMatch._generateDefaultName�
s%���t�*�%�%�&�a��(9�(9�'<�=�=r2c��|}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)rGr�r.�	enumerate�ziprryrr#r�r�)r.r�r�r!r�rH�maxlocr��match_stringlocr4r.�s_m�src�mat�resultss               r0rMzCloseMatch.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��>�>r2r,r�)r5r:r;rAr8r�r�r}r1r$rMr�r�s@r0r-r-`
sV��� �J04�$�
��
$��$�����,�$�
�$�">�c�>�?r2r-c�
��eZdZdZ							dddddd�dedejededed	ed
edejedejed
ejededejef�fd�Z	defd�Z
dd�Zdd�Z�xZ
S)�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
        capital_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�excludeChars�
init_chars�
body_charsr��max�exact�
as_keyword�
exclude_charsr?r@rArBc���|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 z|_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 stringrwrrzUcannot 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=r�r(Fz
 as a keywordr��[r��+�{r��}r"rd�?z\b)r�r1r�r�r5r�r�r?�sorted�
initCharsOrigr@�
bodyCharsOrig�maxSpecified�minLen�maxLenr�rTr�r�rArG�re�escaper�reString�compiler�re_match�parseImpl_regexrM�error)r.rCrDr�rErFrGrHr?r@rArB�
initChars_set�excludeChars_set�re_leading_fragment�repeat�re_body_fragmentr�s                 �r0r1z
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�!�D�I�I�-���"���"����>�>��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�OrWc��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_escaper'r�)rrG)r��max_repr_lens  r0�
charsAsStrz-Word._generateDefaultName.<locals>.charsAsStrqs<���L�*�1��>�A��1�v��$��+�<�!�+�,�u�4�4��r2zW:(�, r�rrdrLrMz,...}r�)r?r@rSrTr�)r.rf�bases   r0r$zWord._generateDefaultNameps���	��>�>�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�@�@�@��r2c��|||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)
r?r�r�rGr@rTr�rSrRrA)	r.r�r�r!r�rH�	bodycharsr7�throwExceptions	         r0rMzWord.parseImpl�s,���C�=����.� ��3����T�B�B����q����x�=���N�N�	�����$���V�X�&���F�l�x��}�	�9��1�H�C��F�l�x��}�	�9�����;����$�!�N�
�
�
�3��>�h�s�m�y�6P�!�N�
�^�^���	��U�Q�Y�'�9�4���>��S�M�Y�.�!%��� ��3����T�B�B��H�U�3�'�'�'r2c��|j||�}|st|||j|��|j�}||j	�fSr,)rYr�r�r��group)r.r�r�r!r�s     r0rZzWord.parseImpl_regex�sF�����x��-��� ��3����T�B�B��j�j�l���F�L�L�N�"�"r2)rwNrrrFNr�)r5r:r;rAr8r�r�r}rxr1r$rMrZr�r�s@r0r>r>�
s����@�H�+/���� �.2�t6�+/�*.��-1�t6��t6��O�O�C�(�t6��	t6�
�t6��
t6��t6����s�+�t6��?�?�3�'�t6��?�?�3�'�t6��t6��o�o�c�*�t6�l�c��6(�@#r2r>c
�z��eZdZdZ		dddd�dededejeded	ejef
�fd
�Z�xZ	S)�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)rArB�charsetrGrHrArBc�D��|xs|}|xs|}t�|�|d||��y)Nr)rFrGrHr�)r.rprGrHrArBr�s      �r0r1z
Char.__init__�s4����+��	�#�4�}��
����1��,�	�	
r2)FN)
r5r:r;rAr8rxr�r�r1r�r�s@r0roro�si����!�.2�	

� �-1�

��

��

����s�+�	

��


��o�o�c�*�

�

r2roc����eZdZdZ			dddd�dedeejefde	de	de	d	e	f�fd
�Z
ed��Zed��Zed
��Z
defd�Zdd�Zdd�Zdd�Zdedefd�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�asMatch�pattern�flags�
as_group_list�as_matchrtruc�
��t�|��|xs|}|xs|}t|t�r*|st	d��d|_|x|_|_||_nJt|d�r3t|d�r'||_|jx|_|_||_ntd��d|jz|_d|_
||_||_|jr|j |_|jr|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() insteadNrvrzCRegex may only be constructed with a string or a compiled RE objectr(F)r�r1rYr&r��_rerWrvrwr(r�rTr�r�rtru�parseImplAsGroupListrM�parseImplAsMatch)r.rvrwrxryrtrur�s       �r0r1zRegex.__init__�s����	����!�2�]���%�X���g�x�(�� �!S�T�T��D�H�+2�2�D�M�D�L��D�J�
�W�i�
(�W�W�g�-F��D�H�+2�?�?�:�D�L�4�=��D�J��U��
�"�D�I�I�-���"���&���������!�6�6�D�N��<�<�!�2�2�D�N�r2c���|jr|jS	tj|j|j�S#tj
$rt
d|j�d���wxYw)Nzinvalid pattern (z) passed to Regex)r{rUrXrvrwr[r�r�s r0rUzRegex.resa���8�8��8�8�O�
X��z�z�$�,�,��
�
�;�;���8�8�
X� �#4�T�\�\�4D�DU�!V�W�W�
X�s�)A�-A1c�.�|jjSr,)rUrr�s r0rYzRegex.re_matchs���w�w�}�}�r2c�(�|jd�duS�Nrw)rYr�s r0r�zRegex.mayReturnEmptys���}�}�R� ��,�,r2rWc�j�djt|j�jdd��S)NzRe:({})z\\�\)�formatr�rvr�r�s r0r$zRegex._generateDefaultName#s)������T�\�\� 2� :� :�6�4� H�I�Ir2c��|j||�}|st|||j|��|j�}t	|j��}|j
�}|r|j�D]
\}}|||<�||fSr,)rYr�r�r�r#rm�	groupdict�items)	r.r�r�r!r�r8�d�k�vs	         r0rMzRegex.parseImpl&s������x��-��� ��3����T�B�B��j�j�l���6�<�<�>�*�����������	�
���1���A��
��C�x�r2c��|j||�}|st|||j|��|j�}|j	�}||fSr,)rYr�r�r��groups�r.r�r�r!r�r8s      r0r|zRegex.parseImplAsGroupList3sI�����x��-��� ��3����T�B�B��j�j�l���m�m�o���C�x�r2c��|j||�}|st|||j|��|j�}|}||fSr,)rYr�r�r�r�s      r0r}zRegex.parseImplAsMatch<sC�����x��-��� ��3����T�B�B��j�j�l�����C�x�r2�replc������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)rar�s �r0r�zRegex.sub.<locals>.paZs����a�y�'�'��-�-r2c�B���jj�|d�Sr)rU�sub)rar�r.s ��r0r�zRegex.sub.<locals>.pa_s����w�w�{�{�4����3�3r2)rtr�rur-r6)r.r�r�s`` r0r�z	Regex.subEs]�������M�N�N��<�<�H�T�N��L��
��<�<�
.�

4��$�$�R�(�(r2)rFFr�)r5r:r;rArr
rU�	RegexFlagr}rxr1r)rYr�r8r$rMr|r}r�r�r�r�s@r0rsrs�s�����6+,�#��,3�"��,3��,3��R�\�\�3�&�'�,3��	,3�
�,3��,3��,3�\�X��X������-��-�J�c�J����)��)�
�)r2rsc�8��eZdZdZed�Z							dddddddd�dedejed	ejed
e	de	dejed
e	dedejedejede	dejede	f�fd�Z
defd�Zdd�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�	)rcrd)z\f�)z\r�
rwNT)�	quoteChar�escChar�escQuote�unquoteResults�endQuoteChar�convertWhitespaceEscapes�
quote_char�esc_char�	esc_quote�	multiline�unquote_results�end_quote_char�convert_whitespace_escapesr�r�r�r�r�r�c����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��jry�xj$t j.t j0zzc_|j'dt3�jd���jrt3|�nd�d
��nE|j'dt3�jd��d�jrt3|�nd�d
��dj+t!j(�j�dd	j+|�dt!j(�j�g��_�jr��jrkt!j6dd	j+d��j8D���dt!j(�j��d��j$���_nGt!j6dt!j(�j��d��j$���_	t!j6�j4�j$��_�j4�_�j j>�_ d�jDz�_#d�_$d�_%y#t jB$rtd�j4�d���wxYw)Nz%quote_char cannot be the empty stringz)end_quote_char cannot be the empty stringrrw�(?:r�z.)r�|c	3��K�|]M}dtj�jd|��dtj�j|d��d����Oy�w)r�Nz(?!z)))rUrVr�)rIrur.s  �r0r�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,)rUrV)rIr�s  r0r�z(QuotedString.__init__.<locals>.<genexpr>�s����!D�1�"�)�)�A�,�!D�s�!z)|(z	.)|(\n|.)�rwzinvalid pattern z passed to Regexr(FT)&r�r1rhr�r�rG�quote_char_len�first_quote_charr��end_quote_char_lenr��has_esc_charr�r�r�r�rUr��re_flagsrrVr��range�	MULTILINE�DOTALLrrvrX�ws_map�unquote_scan_rerWrrYr[rTr�r�r�)r.r�r�r�r�r�r�r�r�r�r�r�r�r��
inner_patternr�s`              �r0r1zQuotedString.__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�<@�<M�<M�.�x�8�SU�W�WY�[�
�

� � ��2�4�3F�3F�q�3I�J�K�4�<@�<M�<M�.�x�8�SU�W�WY�[�
�
�w�w��	�	�$�/�/�*������'���	�	�$�-�-�.�
�
�������.�.�')�z�z�����!D����!D�D�E�F��)�)�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�"�D�I�I�-���"���"�����x�x�	R��/����/?�?O�P�Q�Q�	R�s
�1AP/�/-QrWc��|j|jk(r)t|jt�rd|j��Sd|j�d|j��S)Nzstring enclosed in zquoted string, starting with z
 ending with )r�r�rYr&r�s r0r$z!QuotedString._generateDefaultName
sW���?�?�d�1�1�1�j��O�O�X�7
�)����(;�<�<�.�t���.?�}�T�M`�M`�La�b�br2c���||�jk(xr�j||�xsd}|st||�j���|j	�}|j�}�jr�|�j�j}t|t�r��jr4dj�fd��jj|�D��}n1djd��jj|�D��}�jr&|j!�j�j"�}||fS)Nrwc3���K�|]i}|jd�r�j|jd�n5|jd�r|jd�dn|jd����ky�w)rrdr�r'N)rmr�)rIrr.s  �r0r�z)QuotedString.parseImpl.<locals>.<genexpr>(
s`�����"�"�8=�{�{�1�~����E�K�K��N�3�38�;�;�q�>�U�[�[��^�B�/�"�[�[��^�	,�"�s�A/A2c3�K�|]:}|jd�r|jd�dn|jd����<y�w)rr�rdN)rm)rIrs  r0r�z)QuotedString.parseImpl.<locals>.<genexpr>2
sA����"�
"�/4�k�k�!�n����A��r�*�"�[�[��^�,�"�s�AA)r�rYr�r�r�rmr�r�r�rYr&r�r�r��finditerr�r�r�r�s`     r0rMzQuotedString.parseImpl
s,���
�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�r2)rwNNFTNTr�)r5r:r;rAr�r�r8r�r�rxr1r$rMr�r�s@r0r�r�es$���%�L�N�
O�F��)-�*.�� $�/3�+/�w#��(,�)-�#�-1�)-�w#��w#��/�/�#�&�w#��?�?�3�'�	w#�
�w#��
w#�����,�w#�%)�w#��w#�����%�w#��/�/�#�&�w#��w#��o�o�c�*�w#�#'�w#�rc�c�c�0r2r�c�\��eZdZdZ				d
dd�dededededef
�fd	�Zd
efd�Zdd�Z�xZ	S)�
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']
    rw)�notChars�	not_charsr�rErFr�c�\��t�|��d|_|xs||_t	|j�|_|dkrt
d��||_|dkDr||_nt|_|dkDr||_||_d|jz|_|jdk(|_d|_
y)NFrzacannot specify a minimum length < 1; use Opt(CharsNotIn()) if zero-length char group is permittedrr()r�r1r�r�r��notCharsSetr�rSrTr�rTr�r�r�)r.r�r�rErFr�r�s      �r0r1zCharsNotIn.__init__W
s����	����#���!�-�X��
��t�}�}�-�����7��K��
�
�����7��D�K�"�D�K��1�9��D�K��D�K�!�D�I�I�-���"�k�k�Q�.���"��r2rWc��t|j�}t|�dkDrd|jdd�d�Sd|j�d�S)Nrcz!W:(�
z...)r�)rr�rG)r.�
not_chars_strs  r0r$zCharsNotIn._generateDefaultNamez
sK��2�4�=�=�A�
��}���"��$�-�-��&�1�2�$�7�7��$�-�-���*�*r2c�H�|j}|||vrt|||j|��|}|dz
}t||jzt|��}||kr|||vr|dz
}||kr|||vr�||z
|jkrt|||j|��||||fSrF)r�r�r�r�rTrGrS)r.r�r�r!�notcharsr��maxlens       r0rMzCharsNotIn.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�'�'�'r2)rwrrrr�)
r5r:r;rAr8r}r1r$rMr�r�s@r0r�r�B
sg����,����!#��!#��!#��!#��	!#�
�!#��!#�F+�c�+�(r2r�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*��Zd3d+ed,ed-ed.ef�fd/�
Zd0efd1�Zd4d2�Z	�xZ
S)5�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.
    r�z<SP>r�z<TAB>rdz<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 �wsr�rErFc�8���t����|�_�jdj	�fd��j
D��d��d�_d�jz�_|�_	|dkDr|�_
nt�_
|dkDr|�_
|�_	yy)Nrwc3�@�K�|]}|�jvs�|���y�wr,)�
matchWhite)rI�cr.s  �r0r�z!White.__init__.<locals>.<genexpr>�
s�����J�!��$�/�/�1I�A�J�s��T�rr(r)r�r1r�rr��	whiteStrsr�rTr�rSrTr�)r.r�r�rErFr�s`    �r0r1zWhite.__init__�
s����
��������!�!��G�G�J�t�~�~�J�J��	"�	
�
#���!�D�I�I�-��������7��D�K�"�D�K��1�9��D�K��D�K�r2rWc�F�djd�|jD��S)Nrwc3�BK�|]}tj|���y�wr,)r�r��rIr�s  r0r�z-White._generateDefaultName.<locals>.<genexpr>�
s����C�a�u���q�)�C�s�)r�r�r�s r0r$zWhite._generateDefaultName�
s���w�w�C�4�?�?�C�C�Cr2c�p�|||jvrt|||j|��|}|dz
}||jz}t	|t|��}||kr-|||jvr|dz
}||kr|||jvr�||z
|jkrt|||j|��||||fSrF)r�r�r�rTr�rGrS)r.r�r�r!r�r7s      r0rMzWhite.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�'�'�'r2)z 	
rrrr�)r5r:r;rAr�r8r}r1r$rMr�r�s@r0r�r��
s+������V���g��	
�f��	
�f�	�
	
�f��	�(�
�	�&��	�/��	�+��	�+��	�,��	�,��	�(��	�'��	�&�� 	�"�!�"	�'�#�$!� �&���'�/�I�4 �3� �� �s� �s� �,D�c�D�
(r2r�c���eZdZ�fd�Z�xZS)�
PositionTokenc�>��t�|��d|_d|_yr=rr�s �r0r1zPositionToken.__init__�
s���
����"���"��r2)r5r:r;r1r�r�s@r0r�r��
s
���#�#r2r�c�D��eZdZdZdef�fd�Zdededefd�Zd	d�Z�xZ	S)
�
GoToColumnzaToken to advance to a specific column of input text; useful for
    tabular report scraping.
    �colnoc�0��t�|��||_yr,)r�r1r�)r.r�r�s  �r0r1zGoToColumn.__init__�
s���
������r2r�r�rWc�Z�t||�|jk7r�t|�}|jr|j||�}||krc||j	�rPt||�|jk7r7|dz
}||kr-||j	�rt||�|jk7r�7|SrF)r�rGr�rD�isspace)r.r�r�rHs    r0rJzGoToColumn.preParse�
s����s�H�����)��8�}�H�����*�*�8�S�9���h���S�M�)�)�+���X�&�$�(�(�2��q���	�h���S�M�)�)�+���X�&�$�(�(�2��
r2c��t||�}||jkDrt||d|��||jz|z
}|||}||fS)NzText not in expected column)r�r�)r.r�r�r!�thiscol�newlocr8s       r0rMzGoToColumn.parseImpl�
sT���c�8�$���T�X�X�� ��3�0M�t�T�T��t�x�x��'�)���s�6�"���s�{�r2r�)
r5r:r;rAr}r1r8rJrMr�r�s@r0r�r��
s3�����c�����3��3��r2r�c�>��eZdZdZ�fd�Zdededefd�Zdd�Z�xZ	S)	�	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�|_	d|_
y)NrdzExpected start of line)r�r1rr�r��orig_whiteChars�discardr�rr�r�r�s �r0r1zLineStart.__init__s^���
��������"�u�t���6���������%��w�3�3�D�O�O�D���.��r2r�r�rWc���|dk(r|S|jj||�}d|jvr6|||dzdk(r+|jj||dz�}|||dzdk(r�+|S)Nrrdr)r�rJr�)r.r�r�r8s    r0rJzLineStart.preParse$sy���!�8��J��,�,�'�'��#�6�C��t�+�+�+��s�S�1�W�-��5��,�,�/�/��#��'�B�C��s�S�1�W�-��5��Jr2c�X�t||�dk(r|gfSt|||j|��rF)r�r�r�rLs    r0rMzLineStart.parseImpl.s/���s�H���"���7�N��X�s�D�K�K��>�>r2r�)
r5r:r;rAr1r8r}rJrMr�r�s@r0r�r�s,����,/����3��3��?r2r�c�*��eZdZdZ�fd�Zdd�Z�xZS)�LineEndzTMatches if current position is at the end of a line within the
    parse string
    c���t�|��|jjd�|j	|jd��d|_y)NrdFr�zExpected end of line)r�r1r�r�rr�r�s �r0r1zLineEnd.__init__9s>���
����������%��!�!�$�/�/��!�G�,��r2c���|t|�kr'||dk(r|dzdfSt|||j|��|t|�k(r|dzgfSt|||j|��)Nrdr�rGr�r�rLs    r0rMzLineEnd.parseImpl?sl����X�����}��$��Q�w��}�$�$�X�s�D�K�K��F�F�
�C��M�
!���7�B�;�� ��3����T�B�Br2r�r�r�s@r0r�r�4s����-�	Cr2r�c�*��eZdZdZ�fd�Zdd�Z�xZS)�StringStartzLMatches if current position is at the beginning of the parse
    string
    c�0��t�|��d|_y)NzExpected start of text�r�r1r�r�s �r0r1zStringStart.__init__Ps���
����.��r2c�n�|dk7r-||j|d�k7rt|||j|��|gfSr)rJr�r�rLs    r0rMzStringStart.parseImplTs:���!�8��d�m�m�H�a�0�0�$�X�s�D�K�K��F�F��B�w�r2r�r�r�s@r0r�r�Ks����/�r2r�c�*��eZdZdZ�fd�Zdd�Z�xZS)r�zG
    Matches if current position is at the end of the parse string
    c�0��t�|��d|_y)NzExpected end of textr�r�s �r0r1zStringEnd.__init__as���
����,��r2c���|t|�krt|||j|��|t|�k(r|dzgfS|t|�kDr|gfSt|||j|��rFr�rLs    r0rMzStringEnd.parseImplesg����X��� ��3����T�B�B�
�C��M�
!���7�B�;��
�3�x�=�
 ���7�N� ��3����T�B�Br2r�r�r�s@r0r�r�\s����-�Cr2r�c�>��eZdZdZefed�dedef�fd�Zdd�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.
    ��	wordChars�
word_charsr�c�j��|tk(r|n|}t�|�	�t|�|_d|_y)NzNot at the start of a word)�
printablesr�r1r�r�r��r.r�r�r�s   �r0r1zWordStart.__init__zs.���"+�z�"9�J�y�	�
�����Y����2��r2c��|dk7r=||dz
|jvs|||jvrt|||j|��|gfS�Nrr)r�r�r�rLs    r0rMzWordStart.parseImpl�sL���!�8���q��!�T�^�^�3��C�=����6�$�X�s�D�K�K��F�F��B�w�r2r��	r5r:r;rAr�r8r1rMr�r�s@r0r�r�ps,����*4�3��3�3�3�3�3�r2r�c�>��eZdZdZefed�dedef�fd�Zdd�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�r�r�c�x��|tk(r|n|}t�|�	�t|�|_d|_d|_y)NFzNot at the end of a word)r�r�r1r�r�r�r�r�s   �r0r1zWordEnd.__init__�s6���"+�z�"9�J�y�	�
�����Y����#���0��r2c��t|�}|dkDrB||kr=|||jvs||dz
|jvrt|||j|��|gfSr)rGr�r�r�)r.r�r�r!rHs     r0rMzWordEnd.parseImpl�s[���x�=���a�<�C�(�N���
����/��C�!�G�$�D�N�N�:�$�X�s�D�K�K��F�F��B�w�r2r�rr�s@r0rr�s,����*4�1��1�3�1�3�1�r2rc���eZdZdZddej
edef�fd�
Zde	efd�Z
defd�Zddedef�fd	�
Zddedef�fd
�
Z
def�fd�Zdefd�Zdef�fd
�Zddd�Zdef�fd�Zd�fd�	Zee�d��Zee
�d��Z�xZS)�ParseExpressionz]Abstract subclass of ParserElement, for combining and
    post-processing parsed tokens.
    �exprsr�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,)rYr&)rIr�s  r0r�z+ParseExpression.__init__.<locals>.<genexpr>�s����@�$�:�d�H�-�@�s�c3�d�K�|]'}t|t�r�j|�n|���)y�wr,)rYr&r�)rIr?r.s  �r0r�z+ParseExpression.__init__.<locals>.<genexpr>�s3�������4>�a��3J�D�,�,�Q�/�PQ�Q��s�-0F)
r�r1rY�_generatorTyper�r&r�r	r�r�anyr�r�r.r	r�r�s`  �r0r1zParseExpression.__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�DrWc� �|jddSr,)r	r�s r0rzParseExpression.recurse�s���z�z�!�}�r2c�J�|jj|�d|_|Sr,)r	rr�r�s  r0rzParseExpression.append�s!���
�
���%� � ����r2r
c����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.r
r?r�s   �r0rz ParseExpression.leave_whitespace�s\���
	�� ��+��,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	rrs   �r0rz!ParseExpression.ignore_whitespace�s\���
	��!�)�,��,0�J�J�7�q�!�&�&�(�7�D�J��Z�Z�
/���#�#�I�.�
/����8rc�@��t|t�rN||jvr>t�|�|�|j
D] }|j	|jd��"|St�|�|�|j
D] }|j	|jd��"|S�Nr�)rYrr�r�rr	)r.r�r?r�s   �r0rzParseExpression.ignore�s�����e�X�&��D�,�,�,����u�%����3�A��H�H�T�-�-�b�1�2�3���
�G�N�5�!��Z�Z�
/������)�)�"�-�.�
/��r2c�`�|jj�dt|j��d�S�Nz:(r�)r�r5r8r	r�s r0r$z$ParseExpression._generateDefaultName�s)���.�.�)�)�*�"�S����_�,=�Q�?�?r2c���|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_dt|�z|_|S)Nrdrrr�r()r�r�r�r	rGrYr�r�r�r�r�r�r�r8r�)r.r?r�r�s   �r0r�zParseExpression.streamline�su�������K�
�������	�A�
�L�L�N�	��t�z�z�?�a���J�J�q�M�E��5�$�.�.�1��)�)��%�%�-����"�[�[��^�t�z�z�!�}�o�=��
�$(��!��#�#�u�';�';�;�#��"�"�e�&9�&9�9�"��J�J�r�N�E��5�$�.�.�1��)�)��%�%�-����!�Z�Z���_�u�{�{�1�~�=��
�$(��!��#�#�u�';�';�;�#��"�"�e�&9�&9�9�"�!�C��I�-����r2c��tjdtd��|�|ngdd|gz}|jD]}|j	|��|jg�y�Nr;rdr<)r>rNr?r	rAr6)r.r@�tmpr?s    r0rAzParseExpression.validates]���
�
�h���	
�
!.� 9�}�r�1�E���N�����	�A�
�J�J�s�O�	����R� r2c���t�|��}tjt|�}|j
D�cgc]}|j���c}|_|Scc}wr,)r�rr�rrr	)r.r8r?r�s   �r0rzParseExpression.copy(sD����g�l�n���k�k�/�3�/��'+�z�z�2�!�Q�V�V�X�2��	��
��3s�Ac
���tjr�tj|jvr�|jD]�}t|t�s�|js�!tj|jvs�>tjdjd|t|�j|j�d����t�|�9||�S�NzY{}: setting results name {!r} on {} expression collides with {!r} on contained expressionrYr'r<)rLrYrcrr	rYr�r�r>rNr�r�r5r�r�r.rTrr?r�s    �r0rzParseExpression._setResultsName.s�����>�>��E�E��*�*�+��Z�Z�
���q�-�0��
�
�#�M�M��/�/�0��M�M�E�EK�V�G� � ��J�/�/��M�M�	F�$%�	�
�$�w�&�t�^�<�<r2c��yr,r<r�s r0r�zParseExpression.leaveWhitespaceJr�r2c��yr,r<r�s r0r�z ParseExpression.ignoreWhitespaceMr�r2r�r�r,rV)r5r:r;rAr�rr�rxr1rrrrrrr8r$r�rArrr!r�r�r�r�s@r0rr�s�����"�f�o�o�m�<�"��"�4��m�,���}��
�$��-��
�4�
�=�
�
�}�
�@�c�@�'�M�'�R	!��m��=�8�&�'�"�(�"��'�(�#�)�#r2rc���eZdZdZGd�de�Z	d
dejede	f�fd�
Z
def�fd�Zd
d	�Zd
�Z
d�Zdefd�Z�xZS)r�a
    Requires all given :class:`ParseExpression` 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�*��eZdZ�fd�Zdefd�Z�xZS)�And._ErrorStopc�D��t�|�|i|��|j�yr,)r�r1r)r.r�r3r�s   �r0r1zAnd._ErrorStop.__init__es!����G��d�-�f�-��!�!�#r2rWc��y)N�-r<r�s r0r$z#And._ErrorStop._generateDefaultNameis��r2)r5r:r;r1r8r$r�r�s@r0r�r&ds���	$�	�#�	r2r��	exprs_argr�c�<��t|�}|r�t|vr�g}t|�D]�\}}|turu|t|�dz
krYt	j
tt�||dzz�jd}|jt|�d���xtd��|j|���||ddt�|�5||�|jr�td�|jD��|_t!|jdt"�sg|j%|jdj&|jdj(��|jdj*|_d	|_yd|_d	|_yd	|_d	|_y)
Nrr�r�z0cannot construct And with sequence ending in ...c3�4K�|]}|j���y�wr,�r��rIr?s  r0r�zAnd.__init__.<locals>.<genexpr>������%K�1�a�&6�&6�%K�r�rr�FT)r�r�r5rGr�rrr�r	rr�rXr�r1r0r�rYr�rr�r�r�r)	r.r*r�r	rrur��
skipto_argr�s	        �r0r1zAnd.__init__ls{���&*�)�_���X��&��C�$�U�+�
%���4��8�#��3�u�:��>�)�4:�K�K�+�e�g��a�!�e��.D�5��%��5$�
��
�
�#5�6�*�#5�k�#B�C�'�N����J�J�t�$�
%��E�!�H�
�����)��:�:�"%�%K��
�
�%K�"K�D���d�j�j��m�U�3��)�)��J�J�q�M�,�,�"&�*�*�Q�-�"E�"E�*��'+�j�j��m�&B�&B��#�
!���',��#�!���#'�D�� ��r2rWc����|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)rYrr	r�r.s  r0r�z!And.streamline.<locals>.<genexpr>�sI�������1�o�.�:��G�G�:��q�w�w�r�{�L�9�:��s�AA	r�rc�0�t|dt||��S)N�
parent_anchor)�setattrr�)r�r�r��cur_s    r0r�z And.streamline.<locals>.<lambda>�s��'� �/�3�q�!�9�3�r2c3�4K�|]}|j���y�wr,r-r.s  r0r�z!And.streamline.<locals>.<genexpr>�s����!G�q�!�"2�"2�!G�r�)r	rr�r5rYrr�r�r�r6r�rRr	�
IndentedBlockr6r�nextrr�rr�r0r�)
r.�deleted_expr_markerrur?�prevrr
�subs�
next_firstr�s
         �r0r�zAnd.streamline�s�����:�:������C�R��	��'.�i�#�%�d�j�j��"�o�6�	@�D�A�q��/�/� �"�1�o�6��G�G�&�q�w�w�r�{�L�A�&'�g�g�b�k�D�J�J�q�1�u�4E�&E������,?��
�
�1�q�5�)�	@�*.���T�A�q�@S�7S�a�T��
�
����
�T�Z�Z����A�B��8�	=�I�D�#��5�D���c�7�d�?������C��!��c�=�1��)�)�-0���
��{�{�}��!�$�t�*�d�3�
��%���k�k�-��<���		=�*"�!G�D�J�J�!G�G������;Us�'	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_exceptionrWrGr�)	r.r�r�r!�
resultlist�	errorStopr?�
exprtokensr�s	         r0rMz
And.parseImpl�s���*�*�Q�-�.�.��c�9�5�/�
���Z��	����A�B��	%�A��A�w�#�.�.�(� �	���
�&'�h�h�x��i�&H�O�C��#$�(�(�8�S�)�"D���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,�rYr&r�r�r�rr�s  r0�__iadd__zAnd.__iadd__��;���e�X�&��,�,�U�3�E��%��/�!�!��{�{�5�!�!r2c�v�|dd|gz}|jD]!}|j|�|jr�!yyr,)r	r6r�r7s    r0r6zAnd._checkRecursion�s@��*�1�-���6�����	�A�
���o�.��#�#��	r2c��djd�|jD��}t|�dkDrB|ddt|�dz
�dk(r+|dd}t|�dkDr|ddt|�dz
�dk(r�+d|zdzS)	Nr�c3�2K�|]}t|����y�wr,r/r.s  r0r�z+And._generateDefaultName.<locals>.<genexpr>�s����4�A��Q��4�r.rr�{}r�rLrM)r�r	rG�r.�inners  r0r$zAnd._generateDefaultName�s������4����4�4���%�j�1�n��q�':�C��J��N�':�!;�t�!C��!�B�K�E��%�j�1�n��q�':�C��J��N�':�!;�t�!C��U�{�S� � r2r�)r5r:r;rAr�r�r�rr�rxr1r�rMrGr6r8r$r�r�s@r0r�r�Rsb����"�U��KO�!!�����7�!!�CG�!!�F1�M�1�f�:"��!�c�!r2r�c�~��eZdZdZddej
edef�fd�
Zdef�fd�Z	dd�Z
d�Zdefd	�Z
d�fd
�	Z�xZS)
r�a�Requires that at least one :class:`ParseExpression` 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']]
    r	r�c����t�|�||�|jrCtd�|jD��|_td�|jD��|_yd|_y)Nc3�4K�|]}|j���y�wr,r-r.s  r0r�zOr.__init__.<locals>.<genexpr>
r/r�c3�4K�|]}|j���y�wr,rr.s  r0r�zOr.__init__.<locals>.<genexpr>r/r�T�r�r1r	rr�r0r�rs   �r0r1zOr.__init__�O���
�����)��:�:�"%�%K��
�
�%K�"K�D��"%�%K��
�
�%K�"K�D��"&�D�r2rWc���t�|��|jretd�|jD��|_td�|jD��|_t
d�|jD��|_|Sd|_|S)Nc3�4K�|]}|j���y�wr,r-r.s  r0r�z Or.streamline.<locals>.<genexpr>r/r�c3�4K�|]}|j���y�wr,�r�r.s  r0r�z Or.streamline.<locals>.<genexpr>�����!C�1�!�,�,�!C�r�c3�ZK�|]#}|jxrt|t����%y�wr,�r�rYr�r.s  r0r�z Or.streamline.<locals>.<genexpr>�-����&�BC�� � �=��A�u�)=�%=�=�&���)+F)r�r�r	rr�r�r0r�r�s �r0r�z
Or.streamlinesu���
�����:�:�"%�%K��
�
�%K�"K�D��!�!C��
�
�!C�C�D�O�"%�&�GK�z�z�&�#�D��
��$�D�O��r2c���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}|�|�||k(r|j|_|�t||d|��#t
$r.}
d|
_||
_|j	|
�d}d}Yd}
~
��ld}
~
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,)rr.s  r0r�zOr.parseImpl.<locals>.<genexpr> s����2�!�q�~�~�2�r�T�rfr)r�reverserr3c��|jSr,�r��r?s r0r�zOr.parseImpl.<locals>.<lambda>_���1�5�5�&�r2�rc�Z�|jtt|j��fSr,�r�rGr8�parser_elementrds r0r�zOr.parseImpl.<locals>.<lambda>a�$�����v��C��@P�@P�<Q�8R�7R�.S�r2� no defined alternatives to match)r0r	rJrjrr�r�rir�r�rWrGr��sortrr'r�)r.r�r�r!�	maxExcLoc�maxExceptionr��fatalsr?�loc2�pferb�	best_expr�longest�loc1�expr1r��	max_fatals                  r0rMzOr.parseImpls����	��������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�	� �'�'��#�y�A�A��G�&�
-���e��7�1�:�%�"�N�-�!&���h��Y�!G�J�D�$��t�|�#�T�z�)����
�*�"&��*��#
-�&�*�$�����6�{�Q����� 0��1��!�9�=�=�F�1�I�M�M�1��K�K�$S�K�T��q�	�I��O��#��C��#'�;�;�� ��� ��#�A�4��
��O'�
�$(��!�%&��"��
�
�c�"�#���	��!�
,��(,�C�%��w�w��*�'*��$'�G�G�	����
.��x�=�9�,�#1� �#�h�-����4�$�L�!$�H�
�I��
.��:&�,�(,�C�%��w�w��*�'*��$'�G�G�	���	,�sC�E=�H4�=	H1�#F/�/H1�;&G'�'AH1�0H1�4	I,�=$I'�'I,c��t|t�r|j|�}t|t�stS|j|�Sr,rFr�s  r0�__ixor__zOr.__ixor__prHr2c�R�ddjd�|jD��zdzS)NrLz ^ c3�2K�|]}t|����y�wr,r/r.s  r0r�z*Or._generateDefaultName.<locals>.<genexpr>x�����;�1��A��;�r.rM�r�r	r�s r0r$zOr._generateDefaultNamew�%���U�Z�Z�;��
�
�;�;�;�c�A�Ar2c	�*��tjrstj|jvrWt	d�|j
D��r;t
jdjd|t|�j�d��t�|�1||�S)Nc3�xK�|]2}t|t�xrtj|jv���4y�wr,�rYr�rcrXrr.s  r0r�z%Or._setResultsName.<locals>.<genexpr>��B�������1�c�"�,��I�I��+�+�,�,����8:��{}: setting results name {!r} on {} 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 GrouprXr'r<�
rLrXrcrrr	r>rNr�r�r5r�r�r.rTrr�s   �r0rzOr._setResultsNamez�����>�>��E�E��*�*�+������	���
�
�2�39�&�C���T�
�+�+�3�
 !�
��w�&�t�^�<�<r2r�r�)r5r:r;rAr�rr�rxr1r�rMrxr8r$rr�r�s@r0r�r��sT����"'�f�o�o�m�<�'��'�
�M�
�S�j"�B�c�B�=�=r2r�c�~��eZdZdZddej
edef�fd�
Zdef�fd�Z	dd�Z
d�Zdefd	�Z
d�fd
�	Z�xZS)
r�a�Requires that at least one :class:`ParseExpression` 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']]
    r	r�c����t�|�||�|jrCtd�|jD��|_td�|jD��|_yd|_y)Nc3�4K�|]}|j���y�wr,r-r.s  r0r�z&MatchFirst.__init__.<locals>.<genexpr>�r/r�c3�4K�|]}|j���y�wr,rr.s  r0r�z&MatchFirst.__init__.<locals>.<genexpr>�r/r�TrSrs   �r0r1zMatchFirst.__init__�rTr2rWc�>��|jr|St�|�	�|jret	d�|jD��|_t	d�|jD��|_td�|jD��|_|Sd|_d|_|S)Nc3�4K�|]}|j���y�wr,rXr.s  r0r�z(MatchFirst.streamline.<locals>.<genexpr>�rYr�c3�4K�|]}|j���y�wr,r-r.s  r0r�z(MatchFirst.streamline.<locals>.<genexpr>�r/r�c3�ZK�|]#}|jxrt|t����%y�wr,r[r.s  r0r�z(MatchFirst.streamline.<locals>.<genexpr>�r\r]FT)	r�r�r�r	rr�r�r0r�r�s �r0r�zMatchFirst.streamline�s��������K�
�����:�:�!�!C��
�
�!C�C�D�O�"%�%K��
�
�%K�"K�D��"%�&�GK�z�z�&�#�D����$�D�O�"&�D���r2c���d}d}|jD]}	|j|||�cS|�||k(r|j|_
|�t||d|��#t$r}d|_||_�d}~wt
$r'}|j|kDr|}|j}Yd}~��d}~wt$r=t|�|kDr,t|t|�|j|�}t|�}Y��wxYw)Nr�rk)r	r'r�r�rir�r�rWrGr�r�)	r.r�r�r!rmrnr?rqrbs	         r0rMzMatchFirst.parseImpl�s����	������	.�A�
.��x�x������	.�,�#��C��#'�;�;�� ��� ��#�A�4��
��-'�
�$(��!�%&��"���!�
(��7�7�Y�&�#&�L� #���I����
.��x�=�9�,�#1� �#�h�-����4�$�L�!$�H�
�I��
.�s*�A�	C"�A+�+C"�7B�AC"�!C"c��t|t�r|j|�}t|t�stS|j|�Sr,rFr�s  r0�__ior__zMatchFirst.__ior__�rHr2c�R�ddjd�|jD��zdzS)NrLz | c3�2K�|]}t|����y�wr,r/r.s  r0r�z2MatchFirst._generateDefaultName.<locals>.<genexpr>�r{r.rMr|r�s r0r$zMatchFirst._generateDefaultName�r}r2c	�*��tjrstj|jvrWt	d�|j
D��r;t
jdjd|t|�j�d��t�|�1||�S)Nc3�xK�|]2}t|t�xrtj|jv���4y�wr,r�r.s  r0r�z-MatchFirst._setResultsName.<locals>.<genexpr>�r�r�r�rXr'r<r�r�s   �r0rzMatchFirst._setResultsName�r�r2r�r�)r5r:r;rAr�rr�rxr1r�rMr�r8r$rr�r�s@r0r�r��sS����"'�f�o�o�m�<�'��'��M�� #�J"�B�c�B�=�=r2r�c�r��eZdZdZd
dej
edef�fd�
Zd�Z	def�fd�Z
d
d�Zdefd	�Z
�xZS)r�alRequires all given :class:`ParseExpression` 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
    r	r�c���t�|�||�|jr"td�|jD��|_nd|_d|_d|_d|_y)Nc3�4K�|]}|j���y�wr,r-r.s  r0r�z Each.__init__.<locals>.<genexpr>Fr/r�T)r�r1r	r0r�r��initExprGroupsr�rs   �r0r1z
Each.__init__CsO���
�����)��:�:�"%�%K��
�
�%K�"K�D��"&�D��"���"�����r2c��t|t�r|j|�}t|t�stS|j|�Sr,rFr�s  r0�__iand__z
Each.__iand__MrHr2rWc���t�|��|jr#td�|jD��|_|Sd|_|S)Nc3�4K�|]}|j���y�wr,r-r.s  r0r�z"Each.streamline.<locals>.<genexpr>Wr/r�T)r�r�r	r0r�r�s �r0r�zEach.streamlineTsB���
�����:�:�"%�%K��
�
�%K�"K�D����#'�D���r2c	�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,)rYr�rRr�r.s  r0r�z!Each.parseImpl.<locals>.<genexpr>^s*���� �$%�z�!�S�7I��A�F�F��Q�� �s�4�4T)rFr`rc��|jSr,rcrds r0r�z Each.parseImpl.<locals>.<lambda>�rer2rfrc�Z�|jtt|j��fSr,rhrds r0r�z Each.parseImpl.<locals>.<lambda>�rjr2rgz'Missing one or more required elements (r�)#r�r�r	�opt1maprYr�r�r�rsr��	optionalsrrr��multioptionalsr��
multirequired�requiredr�rjrr1rR�remover�r�rir�rGrlr�r�r8r#r')r.r�r�r!r?�opt1�opt2�tmpLoc�tmpReqd�tmpOpt�multis�
matchOrder�keepMatching�failedro�tmpExprsrqrv�missing�
total_resultsr<s                     r0rMzEach.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�9�=�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�R�ddjd�|jD��zdzS)NrLz & c3�2K�|]}t|����y�wr,r/r.s  r0r�z,Each._generateDefaultName.<locals>.<genexpr>�r{r.rMr|r�s r0r$zEach._generateDefaultName�r}r2r�)r5r:r;rAr�rr�rxr1r�r�rMr8r$r�r�s@r0r�r�	sK���7�r�f�o�o�m�<����"��M��U"�nB�c�Br2r�c����eZdZdZddeeefdef�fd�
Zde	efd�Z
dd�Zddedef�fd	�
Zddedef�fd
�
Z
def�fd�Zdef�fd�Zd
�Zddd�Zdefd�Zee�d��Zee
�d��Z�xZS)�ParseElementEnhancezfAbstract subclass of :class:`ParserElement`, for combining and
    post-processing parsed tokens.
    r�r�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,j/|j,�yy)Nr�)r�r1rYr&r�rr8�
issubclassr�r�r�rkr�r�r�r�rr�r�r�r�rr�r
)r.r�r��expr_strr�s    �r0r1zParseElementEnhance.__init__�s ���
����"��d�H�%��{�{�3��-�H��$�2�2�E�:��/�/��9���D��J��(@�(@�A��x�(���/�/���0A�B���{�{�=�$�/����	���!%�!3�!3�D��"&�"5�"5�D���%�%����t�/I�/I�
&�
�#'�"5�"5�D��"�o�o�D�O� $� 1� 1�D�����#�#�D�$4�$4�5�r2rWc�8�|j�
|jgSgSr,�r�r�s r0rzParseElementEnhance.recurse�s��"�i�i�3��	�	�{�;��;r2c���|j� 	|jj|||d��St||d|��#t$r3}t|t�r|j
�|j|_�d}~wwxYw)NFr�zNo expression defined)	r�r'r|rYrnr�r�r�r�)r.r�r�r!�pbes     r0rMzParseElementEnhance.parseImpl�sv���9�9� �
��y�y�'�'��#�y�u�'�U�U�!��3�0G��N�N��&�
�!�$��0�D�O�O�4O�"�k�k�C�G���
�s�;�	A7�.A2�2A7r
c���t�|�|�|rF|j�:|jj�|_|jj|�|Sr,)r�rr�r�r.r
r�s  �r0rz$ParseElementEnhance.leave_whitespace�sF���
�� ��+���y�y�$� �I�I�N�N�,��	��	�	�*�*�9�5��r2c���t�|�|�|rF|j�:|jj�|_|jj|�|Sr,)r�rr�rr�s  �r0rz%ParseElementEnhance.ignore_whitespace�sF���
��!�)�,���y�y�$� �I�I�N�N�,��	��	�	�+�+�I�6��r2c�T��t|t�rS||jvrCt�|�|�|j
�(|j
j	|jd�|St�|�|�|j
�(|j
j	|jd�|Sr)rYrr�r�rr��r.r�r�s  �r0rzParseElementEnhance.ignore�s�����e�X�&��D�,�,�,����u�%��9�9�(��I�I�$�$�T�%5�%5�b�%9�:�
��
�G�N�5�!��y�y�$��	�	� � ��!1�!1�"�!5�6��r2c�p��t�|��|j�|jj�|Sr,)r�r�r�r�s �r0r�zParseElementEnhance.streamline�s-���
�����9�9� ��I�I� � �"��r2c��||vrt||gz��|dd|gz}|j�|jj|�yyr,)�RecursiveGrammarExceptionr�r6)r.r8r9s   r0r6z#ParseElementEnhance._checkRecursionsP���#�#�+�,<��v�,E�F�F�*�1�-���6���9�9� ��I�I�%�%�o�6�!r2c���tjdtd��|�g}|dd|gz}|j�|jj	|�|jg�yr�r>rNr?r�rAr6�r.r@rs   r0rAzParseElementEnhance.validates_���
�
�h���	
�
� ��M��A��$��'���9�9� ��I�I���s�#����R� r2c�`�|jj�dt|j��d�Sr)r�r5r8r�r�s r0r$z(ParseElementEnhance._generateDefaultNames)���.�.�)�)�*�"�S����^�,<�A�>�>r2c��yr,r<r�s r0r�z#ParseElementEnhance.leaveWhitespacer�r2c��yr,r<r�s r0r�z$ParseElementEnhance.ignoreWhitespace!r�r2r�r�r,rV)r5r:r;rAr
r�r8rxr1rrrMrrrr�r6rAr$r!r�r�r�r�s@r0r�r��s�����6�U�=�#�#5�6�6�$�6�.<��m�,�<�	O��$��-���4��=��
�}�
��M��7�!�?�c�?�
�&�'�"�(�"��'�(�#�)�#r2r�c�l��eZdZdZGd�de�ZGd�de�Zddd�d	ed
edef�fd�Z	dd
�Z
�xZS)r9z�
    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�$��eZdZdef�fd�Z�xZS)�IndentedBlock._Indent�ref_colc�`���t�|��d���|_|j�fd��y)Nzexpected indent at column c�"��t||��k(Sr,�r��r�r�r�r�s   �r0r�z0IndentedBlock._Indent.__init__.<locals>.<lambda>0s���s�1�a�y�G�/C�r2�r�r1r�r9�r.r�r�s `�r0r1zIndentedBlock._Indent.__init__-s+����G���6�w�i�@�D�K����C�Dr2�r5r:r;r}r1r�r�s@r0�_Indentr�,s���	E�C�	E�	Er2r�c�$��eZdZdef�fd�Z�xZS)�IndentedBlock._IndentGreaterr�c�`���t�|��d���|_|j�fd��y)Nz'expected indent at column greater than c�"��t||��kDSr,r�r�s   �r0r�z7IndentedBlock._IndentGreater.__init__.<locals>.<lambda>6s���s�1�a�y�7�/B�r2r�r�s `�r0r1z%IndentedBlock._IndentGreater.__init__3s+����G���C�G�9�M�D�K����B�Cr2r�r�s@r0�_IndentGreaterr�2s���	D�C�	D�	Dr2r�FT�r
�groupedr�r
r�c�R��t�|�|d��||_||_d|_y)NTr�r)r�r1�
_recursive�_groupedr5)r.r�r
r�r�s    �r0r1zIndentedBlock.__init__8s/���	������-�$�����
���r2c�$�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)Nrlr�zinner ����@c��|Sr,r<r�s r0r�z)IndentedBlock.parseImpl.<locals>.<lambda>`s��4�r2)r�rJr�rjr�r�r�r�r9r�r"r�r5r�r)�hexrRrr�r��Groupr�rM)
r.r�r�r!�
anchor_loc�
indent_col�peer_detect_expr�
inner_expr�
sub_indent�nested_block�block�trailing_undentr�s
             r0rMzIndentedBlock.parseImplBs[���W�%�%�h��4�
�	
�	�	���H�j�Y��G���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�)�
�	
r2r�)r5r:r;rAr�r�r�r�rxr1rMr�r�s@r0r9r9&sM����
E�%�E�D��D�9>�t��!��15��HL��!
r2r9c�>��eZdZdZdeeeff�fd�Zd�fd�	Z�xZ	S)�
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
    r�c�2��t�|�|�d|_y�NF�r�r1r�r.r�r�s  �r0r1zAtStringStart.__init__q����
�����!��r2c�J��|dk7r
t||d��t�|�	|||�S)Nrznot found at string start)r�r�rM�r.r�r�r!r�s    �r0rMzAtStringStart.parseImplus.����!�8� ��3�0K�L�L��w� ��3�	�:�:r2r��
r5r:r;rAr
r�r8r1rMr�r�s@r0r�r�fs(����"�U�=�#�#5�6�"�;�;r2r�c�>��eZdZdZdeeeff�fd�Zd�fd�	Z�xZ	S)�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']

    r�c�2��t�|�|�d|_yr�r�r�s  �r0r1zAtLineStart.__init__�r�r2c�^��t||�dk7r
t||d��t�|�
|||�S)Nrznot found at line start)r�r�r�rMr�s    �r0rMzAtLineStart.parseImpl�s6����s�H���"� ��3�0I�J�J��w� ��3�	�:�:r2r�r�r�s@r0r�r�{s(����,"�U�=�#�#5�6�"�;�;r2r�c�:��eZdZdZdeeeff�fd�Zdd�Z�xZ	S)�
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']]
    r�c�2��t�|�|�d|_yr2�r�r1r�r�s  �r0r1zFollowedBy.__init__�s���
�����"��r2c�V�|jj|||��\}}|dd�=||fS)Nri)r�r')r.r�r�r!r@r8s      r0rMzFollowedBy.parseImpl�s3�����!�!�(�C�9�!�E���3���F��C�x�r2r�r�r�s@r0rr�s#����,#�U�=�#�#5�6�#�r2rc�\��eZdZdZ	ddeeefdeje	f�fd�
Z
dd�Z�xZS)�
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

    r��retreatc���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|_||_dt|�z|_d|_|j0j3d��y)NTFrznot preceded by c�8�|jtdd��Sr,)�__delitem__r��r�r�r�s   r0r�z%PrecededBy.__init__.<locals>.<lambda>�s���
�
�e�D�$�>O�0P�r2)r�r1r�rr�r�rFrYr&r�rr8rGrkrrr>r�rTr�r�rr�r�r�r)r.r�rr�s   �r0r1zPrecededBy.__init__�s����	������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����(�3�t�9�4���#�������� P�Qr2c�4�|jrX||jkrt|||j��||jz
}|jj||�\}}||fS|jt
�z}|td||jz
�|}t|||j�}	tdt||jdz�dz�D](}
	|j|t|�|
z
�\}}||fS|	�#t$r}|}	Yd}~�=d}~wwxYwr)rFrr�r�r�r'r�rEr�r�rGr|)r.r�r�r!r�r@r8�	test_expr�instring_slice�	last_expr�offsetr�s            r0rMzPrecededBy.parseImpl�s���:�:��T�\�\�!�$�X�s�D�K�K�@�@��$�,�,�&�E��Y�Y�%�%�h��6�F�A�s�$�C�x���	�	�I�K�/�I�%�c�!�S�4�<�<�-?�&@�3�G�N�&�x��d�k�k�B�I���3�s�D�L�L�1�,<�#=��#A�B�
 ���&�-�-�&��N�(;�f�(D��F�A�s���C�x��
 � ���*�$� #�I��$�s�!D�	D�D�Dr,)rT)
r5r:r;rAr
r�r8r�r�r}r1rMr�r�s@r0rr�s?����<PT�R��-��,�-�R�8>����8L�R�4r2rc��eZdZdZdd�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�rarcs       r0rMzLocated.parseImpl.sx�����i�i�&�&�x��	�PU�&�V���V�!�5�&�#�"6�7�
�#(�
�<� �$�
�7��!$�
�:��������$�$��
�?�"r2Nr�)r5r:r;rArMr<r2r0rrs���6#r2rc�F��eZdZdZdeeeff�fd�Zdd�Zdefd�Z	�xZ
S)r�a�
    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(".")
    r�c�z��t�|�|�d|_d|_dt	|j
�z|_y)NFTzFound unwanted token, )r�r1r�r�r8r�r�r�s  �r0r1zNotAny.__init__Us6���
�����$���"���.��T�Y�Y��?��r2c�v�|jj|||��rt|||j|��|gfS)Nrl)r�rmr�r�rLs    r0rMzNotAny.parseImpl^s9���9�9�#�#�H�c�i�#�H� ��3����T�B�B��B�w�r2rWc�8�dt|j�zdzS)Nz~{rM�r8r�r�s r0r$zNotAny._generateDefaultNamecs���c�$�)�)�n�$�s�*�*r2r�)r5r:r;rAr
r�r8r1rMr$r�r�s@r0r�r�<s1����0@�U�=�#�#5�6�@��
+�c�+r2r�c���eZdZ	ddd�deeefdejeeefdejeeeff�fd�Zdefd�Z	dd	�Z
d
�fd
�	Z�xZS)rN�rr�rrc���t�|�|�|xs|}d|_|}t|t�r|j|�}|j
|�yr2)r�r1r�rYr&r�r)r.r�rr�enderr�s     �r0r1z_MultipleMatch.__init__hsN���	������"�7��������e�X�&��,�,�U�3�E����E�r2rWc�n�t|t�r|j|�}|�
||_|Sd|_|Sr,)rYr&r��	not_ender)r.rs  r0rz_MultipleMatch.stopOnws=���e�X�&��,�,�U�3�E�#(�#4�%������;?����r2c�j�|jj}|j}|jdu}|r|jj}|r	||�||||�\}}	|j
}		|r	||�|	r
|||�}
n|}
|||
|�\}}||z
}�,#ttf$rY||fSwxYwr,)r�r'rDrrjr�r�rW)r.r�r�r!�self_expr_parse�self_skip_ignorables�check_ender�
try_not_enderra�hasIgnoreExprsr��	tmptokenss            r0rMz_MultipleMatch.parseImpl}s����)�)�*�*��#�3�3���n�n�D�0��� �N�N�4�4�M���(�C�(�%�h��Y�?���V�	�%)�%5�%5�!5�5�N���!�(�C�0�!�1�(�C�@�F� �F�!0��6�9�!M���Y��)�#�����
�+�	���F�{��	�s�";B�B2�1B2c
����tjr�tj|jvr�|jg|jj�zD]�}t
|t�s�|js�!tj|jvs�>tjdjd|t|�j|j�d����t�|�=||�Sr )rLrYrcrr�rrYr�r�r>rNr�r�r5r�rr!s    �r0rz_MultipleMatch._setResultsName�s�����>�>��E�E��*�*�+��i�i�[�4�9�9�#4�#4�#6�6�
���q�-�0��
�
�#�M�M��/�/�0��M�M�E�EK�V�G� � ��J�/�/��M�M�	F�$%�	�
�$�w�&�t�^�<�<r2r,r�r�)
r5r:r;r
r8r�r�r�r1rrMrr�r�s@r0rrgs����?C�
�
>B�
��C��&�'�
�����}�c�'9�!:�;�
�
����m�S�&8� 9�:�
��}���8=�=r2rc��eZdZdZdefd�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()
    rWc�8�dt|j�zdzS)NrLz}...rr�s r0r$zOneOrMore._generateDefaultName�����S����^�#�f�,�,r2N)r5r:r;rAr8r$r<r2r0r�r��s���6-�c�-r2r�c���eZdZdZ	ddd�deeefdejeeefdejeeeff�fd�Z	d�fd�	Z
d	efd
�Z�xZS)
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`
    Nrr�rrc�>��t�|�||xs|��d|_y)NrTr)r.r�rrr�s    �r0r1zZeroOrMore.__init__�s$���	����f�&7���8�"��r2c���	t�|�|||�S#ttf$r|t	g|j
��fcYSwxYw)Nr,)r�rMr�rWr#r�r�s    �r0rMzZeroOrMore.parseImpl�sK���	@��7�$�X�s�I�>�>���
�+�	@���R�d�.>�.>�?�?�?�	@�s��(?�?rWc�8�dt|j�zdzS)NrJz]...rr�s r0r$zZeroOrMore._generateDefaultName�r*r2r,r�)
r5r:r;rAr
r8r�r�r�r1rMr$r�r�s@r0r�r��s|���� ?C�#�
>B�#��C��&�'�#�����}�c�'9�!:�;�#�
����m�S�&8� 9�:�#�@�-�c�-r2r�c���eZdZ				ddd�deeefdeeefdedeje	deje	def�fd	�Z
d
efd�Z�xZS)
�
DelimitedListF)�allow_trailing_delimr��delim�combiner�rEr1c���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�)rYr&r�r�r�rr��contentr8�	raw_delimr2r3rr�rEr1r��Combiner�r1)	r.r�r2r3r�rEr1�delim_list_exprr�s	        �r0r1zDelimitedList.__init__�s4���6�d�H�%� �4�4�T�:�D��{�{�=�$�/���?��Q�w� �!=�>�>��?���3��9� �!L�M�M�����U������
�����!�%��D�J��8�!������$8��!��,�,�$�*�*�t�|�|�*C��H�H�q�L��H�H�$�D�$�(�(�Q�,�H
�*
�
���$�$��s�4�:�:��.�O��<�<�%�o�6�O�
����4��8r2rWc�j�dj|jj�|j�S)Nz{0} [{1} {0}]...)r�r5r�r6r�s r0r$z"DelimitedList._generateDefaultName3s&��!�(�(����)@�)@�)B�D�N�N�S�Sr2)r�FNN)
r5r:r;r
r8r�rxr�r�r}r1r$r�r�s@r0r0r0�s����,/��$(�$(�
:9�&+�:9��C��&�'�:9��S�-�'�(�:9��	:9�
�_�_�S�
!�:9��_�_�S�
!�
:9�#�:9�xT�c�Tr2r0c��eZdZd�Zd�Zy)�
_NullTokenc��yr�r<r�s r0�__bool__z_NullToken.__bool__8s��r2c��yr�r<r�s r0r-z_NullToken.__str__;s��r2N)r5r:r;r=r-r<r2r0r;r;7s���r2r;c�\��eZdZdZe�Zefdeeefde	f�fd�
Z
dd�Zdefd�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)
    r��defaultc�z��t�|�|d��|jj|_||_d|_y)NFr�T)r�r1r�r��defaultValuer�)r.r�r@r�s   �r0r1zOpt.__init__is8���	������.��)�)�.�.���#���"��r2c��|j}	|j|||d��\}}||fS#ttf$rN|j}||j
ur,|jrt|g�}|||j<n|g}ng}Y||fSwxYw)NFr�)r�r'r�rWrB�_Opt__optionalNotMatchedr�r#)r.r�r�r!�	self_exprra�
default_values       r0rMz
Opt.parseImplqs����I�I�	�	�#�*�*�8�S�)�RW�*�X�K�C���F�{����
�+�		� �-�-�M��D�$=�$=�=��(�(�)�=�/�:�F�4A�F�9�0�0�1�+�_�F�����F�{��		�s�*�AB�BrWc���t|j�}t|�dkDrB|ddt|�dz
�dk(r+|dd}t|�dkDr|ddt|�dz
�dk(r�+d|zdzS)NrrrLr�rJr�)r8r�rGrMs  r0r$zOpt._generateDefaultName�sy���D�I�I����%�j�1�n��q�':�C��J��N�':�!;�t�!C��!�B�K�E��%�j�1�n��q�':�C��J��N�':�!;�t�!C��U�{�S� � r2r�)r5r:r;rAr;rDr
r�r8rr1rMr$r�r�s@r0r�r�?sI���%�N&�<��?S�#��-��,�-�#�8;�#�� !�c�!r2r�c����eZdZdZ			d
dd�deeefdedejeeefdejeeefdejeeeff
�fd	�Z
d
�Z�fd�Zdd�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)�failOnr��includer�fail_onrIc�f��t�|�|�|xs|}||_d|_d|_||_d|_t|t�r|j|�|_
n||_
dt|j�z|_
t�j�|_|j#�y)NTFzNo match found for )r�r1�
ignoreExprr�r��includeMatchr�rYr&r�rIr8r�r�r�r�ignorer�_update_ignorer)r.r�rJrrKrIr�s      �r0r1zSkipTo.__init__�s����	������"�7�� ���"���"���#�������f�h�'��2�2�6�:�D�K� �D�K�+�c�$�)�)�n�<����w�/�/�1������r2c��|jjj�|jjD]}|jj	|��|j
r&|jj	|j
�yyr,)rOr�r�r�rrM)r.r?s  r0rPzSkipTo._update_ignorer�se����� � �&�&�(����&�&�	#�A��L�L����"�	#��?�?��L�L������0�r2c�D��t�|�|�|j�yr,)r�rrPr�s  �r0rz
SkipTo.ignore�s���
���t�����r2c�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�)rGr�r'rIr�rOr�rjr|r�rWr�r#rN)r.r�r�r!r�rHr!�self_failOn_canParseNext�ignorer_try_parse�tmploc�prev_tmploc�skiptext�
skipresultr;s              r0rMzSkipTo.parseImpl�sn�����x�=���)�)�*�*��(,���(?�D�K�K�$�$�T�	!�7;�l�l�6N�6N�D�L�L�2�2�TX������ �'�3�+�H�f�=�� �,�$����!2�8�V�!D����,��"(�K��
���&�E�PU�V��!��3����T�B�B����H�S�)��!�(�+�
����&�x��i�e�T�H�C���#��J��J����;.�����#�J�/�
��!���
��+�� �s$�	C=�"D�=	D	�D	�D#�"D#)FNNr�)r5r:r;rAr
r�r8rxr�r�r1rPrrMr�r�s@r0r�r��s����;�@�=A�>B��>B���]�C�'�(��������m�S�&8� 9�:�	�
����}�c�'9�!:�;������m�S�&8� 9�:��01��3r2r�c���eZdZdZddej
eeeff�fd�
Z	dd�Z
dd�Zd�fd�Zd�Z
d�fd	�	Zdd
edefd�Zdd
edefd�Zdefd
�Zddd�Zdefd�Zdef�fd�Zd�fd�	Zee�d��Zee�d��Z�xZS)rnaw
    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``.
    r�c�r��tjd��d|_t�|�|d��d|_y)Nrdr�rFr�)r�r��caller_framer�r1�lshift_liner�s  �r0r1zForward.__init__As5���%�3�3�!�<�Q�?���
������/���r2rWc��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�rdr����)r(r\rYr&r�r�r�r�r�r�r�rr�r�r�r�r�r
r�r�r]r�s  r0�
__lshift__zForward.__lshift__Fs���4��(��!��e�X�&��,�,�U�3�E��%��/�!�!���	� �,�,���!�Y�Y�4�4���"�i�i�6�6����!�!��I�I� � ��	�	�0O�0O�	"�	
�#�i�i�6�6����)�)�.�.���������	�	� 5� 5�6�$�2�2��;�B�?����r2c�8�t|t�stS||zSr,)rYr�r�r�s  r0�__ilshift__zForward.__ilshift__\s���%��/�!�!��u�}�r2c���tjd��d}tjrB||jk(r3t
j|jvrtjdd��t�|�)|�}|S)Nrdr�r_z<using '<<' operator with '|' is probably an error, use '<<='r<)r�r�rLr^r]rcrr>rNr�r�)r.r��caller_liner8r�s    �r0r�zForward.__or__bso����-�-�A�6�r�:���=�=��t�/�/�/��D�D��*�*�+�
�M�M�N��
��g�n�U�#���
r2c��|j�ttjrctj|jvrFtjdt|jj|jj��yyyy)NzIForward defined here but no expression attached later using '<<=' or '<<')�filenamer�)r�rLr\rcrr>�
warn_explicit�UserWarningr\rfr�r�s r0�__del__zForward.__del__qsm��
�I�I���6�6��9�9��AX�AX�X��"�"�[���*�*�3�3��(�(�/�/�	
�Y�7�
r2c	�n��|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||
krR|r0|	|x\}
}|	|
<|	|
=|	|=|
|j)�fcYcddd�S|	|
=|
|j)�fcYcddd�S|r4	t�|�=||d	�|	|<n#t,$r}||fx|	|
<|	|<�d}~wwxYw||fx\}
}|	|
<��wxYw#1swYyxYw)N)r�r�r�r���r�r)r�rdzGForward expression was never assigned a value, will not parse any inputr<TFz#Forward recursion without base case)r�rLr[rcrr�r�r5�reversedrTr>rNr�r�r�rMr�rorYrXr�KeyErrorr�)r.r�r�r!�	parse_fnsr�ru�frmr=�memo�prev_loc�prev_result�act_key�peek_key�	prev_peek�new_loc�new_peekr?r�s                  �r0rMzForward.parseImpls�����I�I���:�:��=�=��*�*�+��I��(�(�s�3�B�#�H�R�L��:�
���3��8�8�y�(�!"�Q��J��
�
�
��M�M�Y�%�
��4�4��7�$�X�s�I�>�>�(�
)�
)�/	Q� �0�0�D�-
Q�(,�S�$�	�-A�(B�%��+��k�9�5�%�%���!1�!1�!3�3�/	Q�/	Q���'
Q���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�
�#+�[�-=�-=�-?�#?�?�I/	Q�/	Q�J!��N�'����)9�9�9�M/	Q�/	Q�R%�&�05��0A�(�C�QU�0V��W�
��#1�&�BI�1�� M��X���g�� %��&��@G��?P�P�+��)�d�8�n�5�'
Q��/	Q�/	Q�s~�H+�!.D�:H(�E)�(H(�)F
�H(�	F
�
/H(�9H+�H(�H+�$H(�'G<�;H(�<	H�
H�H�H(�(H+�+H4r
c��d|_|Sr�rrs  r0rzForward.leave_whitespace�s��#����r2c��d|_|Sr2rrs  r0rzForward.ignore_whitespace�s��"����r2c�x�|js-d|_|j�|jj�|Sr2)r�r�r�r�s r0r�zForward.streamline�s2�����#�D���y�y�$��	�	�$�$�&��r2c���tjdtd��|�g}||vr0|dd|gz}|j�|jj	|�|jg�yrr�r�s   r0rAzForward.validate�sg���
�
�h���	
�
� ��M��}�$���"�d�V�+�C��y�y�$��	�	�"�"�3�'����R� r2c���d|_d}	|j�t|j�dd}nd}|jjdz|zS#|jjdz|zccYSxYw)Nz: ...r�i��Nonerf)r�r�r8r�r5)r.�	retStrings  r0r$zForward._generateDefaultName�sn��#����	�	>��y�y�$���	�	�N�5�D�1�	�"�	��>�>�*�*�T�1�I�=�=��4�>�>�*�*�T�1�I�=�=�s�'A�A/c�Z��|j�t�|�	�St�}||z}|Sr,)r�r�rrn)r.r8r�s  �r0rzForward.copy
s.����9�9� ��7�<�>�!��)�C��D�L�C��Jr2c	�
��tjrctj|jvrG|j�;tjdjd|t|�j�d��t�|�-||�S)NzO{}: setting results name {!r} on {} expression that has no contained expressionrZr'r<)rLrZrcrr�r>rNr�r�r5r�r)r.rTrr�s   �r0rzForward._setResultsNamesu����3�3��:�:��*�*�+��y�y� ��
�
�7�7=�v�8�$��T�
�@S�@S�8� !���w�&�t�-=�>�>r2c��yr,r<r�s r0r�zForward.leaveWhitespace%r�r2c��yr,r<r�s r0r�zForward.ignoreWhitespace(r�r2r,)rWrnr�r�rVr�)r5r:r;rAr�r�r
r�r8r1r`rbr�rirMrxrrr�rAr$rrr!r�r�r�r�s@r0rnrn$s�����8 �f�o�o�e�M�3�4F�.G�H� �
�,�
��]Q�~�$��-���4��=���M��
!�>�c�>��m��?�&�&�'�"�(�"��'�(�#�)�#r2rnc�4��eZdZdZddeeeff�fd�
Z�xZS)�TokenConverterzW
    Abstract subclass of :class:`ParseExpression`, for converting parsed results.
    r�c�2��t�|�|�d|_yr�)r�r1r��r.r�r�r�s   �r0r1zTokenConverter.__init__2s���
�������r2r�)	r5r:r;rAr
r�r8r1r�r�s@r0r�r�-s#���� �U�=�#�#5�6� � r2r�c�p��eZdZdZ		ddd�dedededejef�fd�Z	d	ef�fd
�Z
d�Z�xZS)
r7a�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)�
joinStringr��join_string�adjacentr�c���t�|�|�|�|n|}|r|j�||_d|_||_d|_yr2)r�r1rr�r�r�r)r.r�r�r�r�r�s     �r0r1zCombine.__init__JsK���	�����#-�#9�Z�{�
���!�!�#� ��
�"���$��� ��r2rWc�n��|jrtj||�|St�|�	|�|Sr,)r�r�rr�r�s  �r0rzCombine.ignore\s4����=�=�� � ��u�-���
�G�N�5�!��r2c���|j�}|dd�=|tdj|j|j��g|j
��z
}|jr|j�r|gS|S)Nrw)rV)rr#r��
_asStringListr�r�r��haskeys)r.r�r�rQ�retTokss     r0rRzCombine.postParsecsm���.�.�"���A�J��<�
�W�W�Y�,�,�T�_�_�=�
>�?�t�GX�GX�
�	
�������� 1��9���Nr2)rwT)
r5r:r;rAr�r8rxr�r�r1rrRr�r�s@r0r7r77s_����*��	!�,0�
!��!��!��	!��O�O�C�(�
!�$�}��
r2r7c�4��eZdZdZddedef�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']]
    r��aslistc�@��t�|�|�d|_||_yr2)r�r1r��
_asPythonList)r.r�r�r�s   �r0r1zGroup.__init__�����
��������#��r2c��|jrBtjt|t�r|j	��St|��S|gSr,)r�r#rrYrUr�rPs    r0rRzGroup.postParse�sS������$�$��i��6�� � �"��
��)�_��
��;�r2r��	r5r:r;rAr�rxr1rRr�r�s@r0r�r�ps ����($�]�$�D�$�
r2r�c�4��eZdZdZddedef�fd�
Zd�Z�xZS)r�arConverter 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.
    r��asdictc�@��t�|�|�d|_||_yr2)r�r1r��
_asPythonDict)r.r�r�r�s   �r0r1z
Dict.__init__�r�r2c���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)Nrrrwrdzdcould not extract dict values from parsed results - Dict expression must contain Grouped expressions)r5rGrYr}r8rhr$r#rrXr�r�r�r��as_dict)	r.r�r�rQru�tok�ikey�	dictvaluer�s	         r0rRzDict.postParse�sf���	�*�	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�"&�"2�"2�I�;�A�	�A��'!�(�#�N��C��4�'�(�s�"E�E)r�r�r�s@r0r�r��s"���'�R$�]�$�D�$�
%Br2r�c�b��eZdZdZd
deeefdef�fd�
Zd�fd�Z	d�fd�Z
d�Zdefd	�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`.)
    r�r�c�R��|durtt��}t�|�
|�y)N.)r�r�r�r1r�s   �r0r1zSuppress.__init__s#����3�;���	�*�D�
����r2rWc���t|jt�rtt	|��|zSt
�|�|�Sr,)rYr�r�rr�r�r�r�s  �r0r�zSuppress.__add__�4����d�i�i��.��F�5�M�*�U�2�2��7�?�5�)�)r2c���t|jt�rtt	|��|z
St
�|�|�Sr,)rYr�r�rr�r�r�r�s  �r0r�zSuppress.__sub__r�r2c��gSr,r<rPs    r0rRzSuppress.postParser4r2c��|Sr,r<r�s r0rzSuppress.suppresss���r2r�r�)r5r:r;rAr
r�r8rxr1r�r�rRrr�r�s@r0rr�s@����<�U�=�#�#5�6��$��
*�*���-�r2rrKc�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|�dkDr|djjdz|z}tjjd|�dt
||��d|�d|�d�	�	�|�}tjjd	|�d|�d��|S#t$r,}tjjd	|�d
|�d���d}~wwxYw)N���r'r�.z>>entering z(line: rgz)
z
<<leaving z
 (exception: z (ret: )r5rGr�rl�stderrrnr�rX)�paArgs�thisFuncr�r�r�r8r�rKs       �r0�zztrace_parse_action.<locals>.z>s�����:�:�����+���1�a��v�;��?��a�y�*�*�3�3�c�9�H�D�H��
�
���;�x�j���Q��
�~�R��s�"�Q�E�QT�U�V�	��V�*�C�	�
�
���:�h�Z�w�s�g�S�A�B��
��	�	��J�J���z�(��=���S�I�J���	�s�;B(�(	C�1'C�C)r�r5)rKr�s` r0�trace_parse_actionr�#s%���2	�A��A�����A�J��Hr2�empty�
line_start�line_end�string_start�
string_endz\\[\\[\]\/\-\*\.\$\+\^\?()~ ]c��|ddSrr<r
s   r0r�r�Xs��A�a�D��G�r2z\\0?[xX][0-9a-fA-F]+c�P�tt|djd�d��S)Nrz\0xrc)�chrr}rqr
s   r0r�r�[s��C��A�a�D�K�K��/��4�5�r2z	\\0[0-7]+c�8�tt|dddd��S)Nrrr()r�r}r
s   r0r�r�^s��C��A�a�D���H�a�(�)�r2z\])rFr)rJr��negate�bodyr�r�c���d��	dj�fd�tj|�jD��S#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.)
    c
��t|t�s|Sdjd�tt	|d�t	|d�dz�D��S)Nrwc3�2K�|]}t|����y�wr,)r�r�s  r0r�z+srange.<locals>.<lambda>.<locals>.<genexpr>�s����E��S��V�E�r.rr)rYr#r�r��ord)�ps r0r�zsrange.<locals>.<lambda>�sE���!�\�*���
�W�W�E�U�3�q��t�9�c�!�A�$�i�!�m�%D�E�
E�r2rwc3�.�K�|]}�|����y�wr,r<)rI�part�	_expandeds  �r0r�zsrange.<locals>.<genexpr>�s�����W�4�y���W�s�N)r��_reBracketExprr�r�rX)r�r?r�s  @r0�sranger�lsL���6	F��
��w�w�W�>�3N�3N�q�3Q�3V�3V�W�W�W�������s�6=�	A�Ac�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,r<)r�r�r��toknr�r/s    ��r0r�ztoken_map.<locals>.pa�s!���./�0�d��T�!�D�!�0�0��0s�r5r�)r�r5)r/r�r�r�s``  r0�	token_mapr��s2���J1���j�'�$��*D�*M�*M�N�I��B�K�
�Ir2c�0�tj�j}|�ytjt
j|�}|jj�D]4\}}t|t�s�|jr�$|j|��6y)zy
    Utility to simplify mass-naming of parser elements, for
    generating railroad diagram with named subdiagrams.
    N)
rl�	_getframe�f_backr�r�types�	FrameType�f_localsr�rYr�r�r))�
calling_framerT�vars   r0�autoname_elementsr��sp��
�M�M�O�*�*�M�����K�K�����?�M�"�+�+�1�1�3��	��c��c�=�)�#�.�.��L�L���r2z4"(?:[^"\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 string�uzunicode string literalz#[\0xc0-\0xd6\0xd8-\0xf6\0xf8-\0xff]z[\0xa1-\0xbf\0xd7\0xf7]r�c��yr,r<r<r2r0�nullDebugActionr�r�r2c��yr,r<r<r2r0�traceParseActionr�r�r2c��yr,r<r<r2r0�conditionAsParseActionr�
r�r2c��yr,r<r<r2r0�tokenMapr�
s��r2rV)r'r�r�)��collectionsr�osr�rrrrrr	r
rrr
r�abcrr�enumr�stringrr>rUrl�collections.abcrr�r��operatorr�	functoolsr�	threadingr�pathlibr�utilrrrrrrrrr�r r�r!�
exceptions�actionsr<r#r$�unicoder%�maxsizer�r8�bytesr&r�r��version_infor)r>rLrcrlrorUr�rxr��warnoptions�environr1�sumrGrOrlr�r�r�rr0r�rEr��
GeneratorTyper
r}�ParseImplReturnType�PostParseReturnTyper�r�rXr�r�r�r��ascii_uppercase�ascii_lowercase�alphas�Latin1�
identchars�identbodychars�nums�hexnumsr"r��	printable�
whitespacer�r��StackSummaryr�r�r�r�r�r�r�r�r�r�rkr�r�r�rr%r*r-r>rorsr�r�r�r�r�r�r�r�r�r�rrr�r�r�r�r�r9r�r�rrrr�rr�r�r0r;r�r�rnr�r7r�r�rr�r)r�r�r�r�r�r4�_escapedPunc�_escapedHexChar�_escapedOctChar�_singleChar�
_charRangerr�r�r�r��dbl_quoted_string�sgl_quoted_stringrpr��python_quoted_string�unicode_string�
alphas8bit�punc8bitrO�valuesrYr��sglQuotedString�dblQuotedString�quotedString�
unicodeString�	lineStart�lineEnd�stringStart�	stringEndr�r�r�r�)r�r�s00r0�<module>rs�
��
�	�
�����$��
���	�
�$������������:�&��;�;��!�5�\��%��c�	�
�)�4���v��)������.�~��,*�$�*�D$�;�$�4�$�%�K�%�D�%�#���!�?�?�3�/��?E���s�?S��	��"��O�O�R�Z�Z�^�^�$@�A����
��
���	���������$�$���C��H�o���L�(�<�*@�@�A����R��W���l�^�S�
 �!��c�<�
 �#�
%�&��c�3��
%�s�
*�+�-�����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��
�	�	�&�"8�"8�	8��
�
%�
%�
0�
0�
�"�)�)�8�8����
��
���T�M�	�
�W�W��!1�!1�P�A�Q�f�>O�>O�5O�a�P�
Q�
�04��y�-�-�4�6�tMR����!'����!5��EI����:GL�
��
��
�#2�
�?C�
�&�
	@��	@��	@�
�	@��		@�
�	@��
	@�"�U��U�	�U��U�
�	U�
�U�R�T�C�T�p<&
�=�&
�R	#�M�	#�?�e�?�2?�e�2?�j�G��"?��?�%,�
�!�s7�e�s7�l?�g�?�6B�g�B�2T?��T?�nz#�5�z#�z
�4�
�,X)�E�X)�vZ�5�Z�zM(��M(�`J(�E�J(�Z#�E�#����>,?�
�,?�^C�m�C�.�-��"C�
�C�(�
��4�m��6i$�m�i$�Z`!�/�`!�F]=��]=�@q=��q=�hkB�?�kB�\k$�-�k$�^=
�'�=
�@;�'�;�*;�%�;�B!�$�!�HO�$�O�d'#�!�'#�T(+�
 �(+�VJ=�(�J=�Z-��-�@-��-�D>T�'�>T�B��G!�
�G!�T��U�
 �U�pE$�!�E$�R �(� �6�n�6�r"�N�"�JTB�>�TB�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���"�c�"�c�"�J+�k�+�\��	�
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�'���]�#��$��#�����
��	�
�����	��#�$��%���$�%��&���+�,�!�-�!��)������MxQ��Zw's�2a�a�7a#�a#

Zerion Mini Shell 1.0