????

Your IP : 3.147.70.194


Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/pyparsing/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/pyparsing/__pycache__/core.cpython-311.pyc

�

�܋f>A�
��UddlZddlZddlmZmZmZmZmZmZmZm	Z	m
Z
mZddlm
Z
mZddlmZddlZddlZddlZddlZddlZddlmZddlZddlZddlmZddlmZddlmZdd	l m!Z!d
dl"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z+m,Z-d
dl.Td
dl/Td
d
l0m1Z1m2Z2d
dl3m4Z4ej5Z6e7e8fZ9ee:dfe;d<ej<dkrddlm=Z=n
Gd�d��Z=Gd�de%��Z>Gd�de%��Z?Gd�de��Z@de@ddfd�ZAde@ddfd�ZBd�d�ZC[%d eje7d!ejDe7deEfd"�ZFeFejGejH�Id#����r
eC��eJeKeLeMeNeOePeQeReSeThZUejVZWeegefee1gefeeXe1gefee7eXe1geffZYeegeEfee1geEfeeXe1geEfee7eXe1geEffZZee7eXd$e[gdfZ\ee7eXd$eEgdfZ]ee7eXeXd$e1eEgdfZ^ee7eXd$e[eEgdfZ_ej`ejazZbe4jcjdZde4jcjeZed%Zfefd&zZgebefzZhd'�id(�ejjD����Zkdalejme;d)<d�d+�Zn	d�d-eZd.e7d/eEdeYfd0�Zo	d�d1e7d2eXd3d$d4eEfd5�Zp	d�d1e7d6eXd7eXd3d$d8e1d4eEfd9�Zq	d�d1e7d2eXd3d$d:e[d4eEf
d;�Zrd<�ZsGd=�d$e
��ZtGd>�d?et��ZuGd@�dAet��ZvGdB�dCev��ZwGdD�dEev��ZxGdF�dGev��ZyGdH�dIey��Zzeyet_{GdJ�dKev��Z|GdL�dMey��Z}GdN�dOe|��Z~GdP�dQev��ZGdR�dSev��Z�GdT�dUe���Z�GdV�dWe���Z�GdX�dYev��Z�GdZ�d[ev��Z�Gd\�d]ev��Z�Gd^�d_ev��Z�Gd`�daev��Z�Gdb�dce���Z�Gdd�dee���Z�Gdf�dge���Z�Gdh�die���Z�Gdj�dke���Z�Gdl�dme���Z�Gdn�doe���Z�Gdp�dqet��Z�Gdr�dse���Z�Gdt�due���Z�Gdv�dwe���Z�Gdx�dye���Z�Gdz�d{et��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�e���Z�Gd��d���Z�Gd��d�e���Z�e�ZDGd��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�eYdeYfd��Z�ew����d���Z�e�����d���Z�e�����d���Z�e�����d���Z�e�����d���Z�e�e(d�d�������d����Z�e�d�����d����Z�e�d�����d����Z�e�e�ze�ze�d�d
����zZ�e�e�e�d���ze�z��Z�eyd���e�d�����d���ze�e�e�e�z������d���zd�zZ�d�e7de7fd��Z�deYfd��Z�d�d��Z�e�e�d���d�z����d���Z�e�e�d���d�z����d���Z�e�e�d���d�ze�d���d�zz����d¦�Z�e�d�e����z����dĦ�Z�e�dŦ�Z�e�dƦ�Z�dDŽe�������D��Z�eete;d�<e�Z�eoZ�esZ�e�Z�e�Z�e�Z�e�Z�e�Z�e�Z�e�Z�e�Z�e�Z�dS)��N)
�
NamedTuple�Union�Callable�Any�	Generator�Tuple�List�TextIO�Set�Sequence)�ABC�abstractmethod)�Enum)�Iterable)�
itemgetter)�wraps)�RLock)�Path�)	�
_FifoCache�_UnboundedCache�__config_flags�_collapse_string_to_ranges�_escape_regex_range_chars�_bslash�_flatten�LRUMemo�
UnboundedMemo)�*)�ParseResults�_ParseResultsWithOffset)�pyparsing_unicode.�str_type)��)�cached_propertyc��eZdZd�Zdd�ZdS)r&c��||_dS�N)�_func)�self�funcs  �_/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/pyparsing/core.py�__init__zcached_property.__init__Qs
���D�J�J�J�Nc�X�|�|��x}|j|jj<|Sr))r*�__dict__�__name__)r+�instance�owner�rets    r-�__get__zcached_property.__get__Ts*��;?�:�:�h�;O�;O�O�C�(�#�D�J�$7�8��Jr/r))r2�
__module__�__qualname__r.r6�r/r-r&r&Ps7������	�	�	�	�	�	�	�	�	r/r&c�j�eZdZdZdZdZd�e��D��Zd���Z	dS)�
__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
    �
compatibilityTc�<�g|]}|�d���|��S��_��
startswith��.0�__s  r-�
<listcomp>z__compat__.<listcomp>j�)��B�B�B��r�}�}�S�/A�/A�B�"�B�B�Br/z(
        collect_all_And_tokens
        N)
r2r7r8�__doc__�
_type_desc�collect_all_And_tokens�locals�
_all_names�split�_fixed_namesr9r/r-r;r;YsQ������
�
�!�J�!��B�B�v�v�x�x�B�B�B�J���E�G�G��L�Lr/r;c��eZdZdZdZdZdZdZdZdZ	dZ
dZd�e��D��Z
d�e
D��Zd�e
D��Zed	d���ZdS)
�__diag__�
diagnosticFc�<�g|]}|�d���|��Sr>r@rBs  r-rEz__diag__.<listcomp>|rFr/c�<�g|]}|�d���|��S)�warnr@�rC�names  r-rEz__diag__.<listcomp>}s)��M�M�M�t�T�_�_�V�5L�5L�M�d�M�M�Mr/c�<�g|]}|�d���|��S)�enable_debugr@rTs  r-rEz__diag__.<listcomp>~s)��S�S�S�T�4�?�?�>�3R�3R�S�D�S�S�Sr/�returnNc�D�|jD]}|�|���dSr))�_warning_names�enable)�clsrUs  r-�enable_all_warningsz__diag__.enable_all_warnings�s3���&�	�	�D��J�J�t�����	�	r/�rXN)r2r7r8rH�)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_expressionsrJrKrZ�_debug_names�classmethodr]r9r/r-rOrOps��������J�05�-�05�-�%*�"�(-�%�$)�!�,1�)�/4�,�(-�%�B�B�v�v�x�x�B�B�B�J�M�M�z�M�M�M�N�S�S�Z�S�S�S�L������[���r/rOc�2�eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
S)�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)r2r7r8rGr_r`rarbrcrdrerfr9r/r-rjrj�sL��������,12�-�01�-�%&�"�()�%�$%�!�,-�)�/0�,�()�%�%�%r/rj�	diag_enumrXc�D�t�|j��dS)zO
    Enable a global pyparsing diagnostic flag (see :class:`Diagnostics`).
    N)rOr[rU�rps r-�enable_diagrs�s��
�O�O�I�N�#�#�#�#�#r/c�D�t�|j��dS)zP
    Disable a global pyparsing diagnostic flag (see :class:`Diagnostics`).
    N)rO�disablerUrrs r-�disable_diagrv�s ��
���Y�^�$�$�$�$�$r/c�8�t���dS)zU
    Enable all global pyparsing diagnostic warnings (see :class:`Diagnostics`).
    N)rOr]r9r/r-r]r]�s��
� � �"�"�"�"�"r/�cmd_line_warn_options�warn_env_varc�@�t|��}|D]�}|dz�d��dd�\}}}}}|����d��s|s|s|r|dkrd}�^|����d��r|dvrd}��|S)	Nz::::�:rm�i�	pyparsingT)r}�F)�boolrL�lowerrA)	rxryr[�warn_opt�w_action�	w_message�
w_category�w_module�w_lines	         r-�_should_enable_warningsr��s����,�
�
�F�)�	�	��=E��=N�<U�<U��=
�=
�
�1�"�=�9��)�Z��6��~�~���*�*�3�/�/�	��	�(�	�,4�	�9A�[�9P�9P��F�F�
�^�^�
�
�
(�
(��
-�
-�	�(�>O�2O�2O��F���Mr/�PYPARSINGENABLEALLWARNINGS�
ParserElement�
0123456789�ABCDEFabcdefr~c�.�g|]}|tjv�|��Sr9)�string�
whitespace�rC�cs  r-rErEs%��P�P�P�A�Q�f�>O�5O�5O�a�5O�5O�5Or/�_trim_arity_call_liner$c�B��������tvr�fd�Sd�d�d
d��d}tptjd���datdtd	|zf�������fd
�}t	�dt	�d��j��}||_�j|_|S)zAdecorator to trim function calls to match the arity of the targetc����|��Sr)r9)�s�l�tr,s   �r-�<lambda>z_trim_arity.<locals>.<lambda>s���t�t�A�w�w�r/rFc�T�tj||���}|d}|dd�gS)N��limit���rk)�	traceback�
extract_tb)�tbr��frames�
frame_summarys    r-r�z_trim_arity.<locals>.extract_tbs2���%�b��6�6�6���r�
�
��b�q�b�!�"�"r/rorkr�r�rc����		�|�d��}d�|S#t$rB}�r�|j}�|d���ddd��
k}~|r��	kr
�dz
�Yd}~�Y�d}~wwxYw)NrTrkr�r�)�	TypeError�
__traceback__)�argsr5�ter��trim_arity_type_errorr��found_arityr,r��	max_limit�pa_call_line_synths     ������r-�wrapperz_trim_arity.<locals>.wrappers����	�
��d�D����L�)��"���
���
�
�
�����)�B�"�
�2�Q�/�/�/��3�B�Q�B�7�;M�M�*��,�%� �9�,�,�!�Q�J�E�$�H�H�H�H������!
���s��
A!�7A�A�A!r2�	__class__�r)�_single_arg_builtinsr�r��
extract_stack�getattrr2rG)	r,r��	LINE_DIFFr��	func_namer�r�r�r�s	``   @@@@r-�_trim_arityr�s����������#�#�#�&�&�&�&�&�
�E��K�#�#�#�#��I�3�Z�i�6M�TU�6V�6V�6V�WY�6Z��/��2�4I�!�4L�y�4X�Y������������8��j�'�$��*D�*D�*M�N�N�I� �G���l�G�O��Nr/F�fn�message�fatalc�����|�|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`

    Nzfailed user-defined conditionc�V��t�|||����s
�||����dSr))r)r�r�r��exc_typer��msgs   ���r-�paz%condition_as_parse_action.<locals>.paVs=����B�B�q�!�Q�K�K� � �	&��(�1�a��%�%�%�	&�	&r/)�ParseFatalException�ParseExceptionr�r)r�r�r�r�r�r�s`   @@r-�condition_as_parse_actionr�Bsk����� �(�'�'�.M�C�&+�?�"�"��H�	�R���B�
�2�Y�Y�&�&�&�&�&�&��Y�&��Ir/�instring�loc�expr�	cache_hitc���|rdnd}td�|||t||��t||��t	||��dt||��dz
z����dS)Nrr~z&{}Match {} at loc {}({},{})
  {}
  {}^� r)�print�format�lineno�col�line)r�r�r�r��
cache_hit_strs     r-�_default_start_debug_actionr�^s���%�,�C�C�"�M�	�6�=�=�����s�H�%�%��C��"�"��S�(�#�#��s�3��)�)�A�-�.�
�
�����r/�startloc�endloc�toksc�~�|rdnd}td�|||�������dS)Nrr~z{}Matched {} -> {})r�r��as_list)r�r�r�r�r�r�r�s       r-�_default_success_debug_actionr�qsA��%�,�C�C�"�M�	�
�
%�
%�m�T�4�<�<�>�>�
J�
J�K�K�K�K�Kr/�excc	��|rdnd}td�||t|��j|����dS)Nrr~z {}Match {} failed, {} raised: {})r�r��typer2)r�r�r�r�r�r�s      r-�_default_exception_debug_actionr�}sS��%�,�C�C�"�M�	�*�1�1��4��c���!3�S�	
�	
�����r/c��dS)zG'Do-nothing' debug action, to suppress debugging output during parsing.Nr9)r�s r-�null_debug_actionr������r/c'���eZdZUdZdZeed<dZeed<dZ	e
jeed<e
ded	dfd
���Ze
ded	dfd���ZGd
�de��Zd�defd�Zded	dfd�Zd�d�Z	d�dd�dededed	dfd�Zd�d�Zd�ded	dfd�Zded	dfd�Zded	dfd�Zded	dfd �Zd!ed	dfd"�Zd#�Z d$�Z!d�d%�Z"d&�Z#	d�d	e$e%e&ffd'�Z'd�d(ed)e%d*ed	e%fd+�Z(d(ed)e%d	efd,�Z)e*��Z+iZ,e
j-e$e%d-efe$e%e.e&e/fffed.<iZ0e*��Z1d/d/gZ2	d�d	e$e%e&ffd0�Z3e'Z4e
d�d1���Z5dZ6dZ7e
d�d2���Z8e
	d�dd3�d4e
je%d	dfd5���Z9e
d�dd3�d4e%d7ed	dfd8���Z:	d�dd9�d(ed:ed;ed	e&fd<�Z;e<dfde<d=�d(ed>e%d?ed@edAe%d	e=e$e&e%e%fddffdB�Z>ddC�d(ed@ed	efdD�Z?e<fde<d=�d(ed>e%d@edAe%d	e&f
dE�Z@e<dfddF�d(edGe%dHed	e=eddffdI�ZAd�dJ�ZBd�dK�ZCd�dL�ZDd�dM�ZEd�dN�ZFd�dO�ZGd�dP�ZHd�dQ�ZId�dR�ZJd�dS�ZKd�dT�ZLd�dU�ZMd�dV�ZNdZOdW�ZPd�ded	dfdX�ZQd�dY�ZRd�dZed	dfd[�ZSd�dZed	dfd\�ZT	d�de.eUeefd]ed	dfd^�ZVd�d_�ZWd�da�ZXdbeYdceZdde[d	dfde�Z\d�dfed	dfdg�Z]e^d	efdh���Z_e`di���Zaded	dfdj�Zbe^d	efdk���Zcd	efdl�Zdd	efdm�Zed�dn�Zfd	egdfdo�Zhdp�Zid�d�dq�Zj		d�dd9�dse.eekelfdted:ed;ed	e&f
du�Zmdv�Zndw�Zo	d�dd9�dxed:ed;ed	efdy�Zp								d�dddddd{�d|e.eeqefd:ed}e
je.defd~eded�ed�eree&gefd�e
jeld�ed;ed�ed�ed�ed�eree&gefd	e$eeqe$ee.e&e/ffffd��Zs			d�d�e.elekefd�e%d�ed�ed	df
d��ZteZueZveZweZxeZyeZzeZ{eZ|e(Z}e)Z~e5Ze9Z�e:Z�e;Z�e>Z�e@Z�e?Z�eVZ�eWZ�e\Z�e]Z�e_Z�ebZ�emZ�esZ�eSZ�eTZ�dS)�r�z)Abstract base level parser element class.z 
	
�DEFAULT_WHITE_CHARSF�verbose_stacktraceN�_literalStringClass�charsrXc�h�|t_tD]}|jrt	|��|_�dS)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  r-�set_default_whitespace_charsz*ParserElement.set_default_whitespace_chars�s@��-2�
�)�#�	-�	-�D��)�
-�"%�e�*�*����	-�	-r/r\c��|t_dS)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�)r\s r-�inline_literals_usingz#ParserElement.inline_literals_using�s��(-0�
�)�)�)r/c�p�eZdZUejeed<ejeed<ejeed<dS)�ParserElement.DebugActions�	debug_try�debug_match�
debug_failN)	r2r7r8�typing�Optional�DebugStartAction�__annotations__�DebugSuccessAction�DebugExceptionActionr9r/r-�DebugActionsr��sN��������?�#3�4�4�4�4��_�%7�8�8�8�8��O�$8�9�9�9�9�9�9r/r��savelistc��t��|_d|_d|_d|_d|_||_d|_ttj
��|_d|_d|_
d|_t��|_d|_d|_d|_d|_d|_|�ddd��|_d|_d|_g|_dS)NTFr~)�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  r-r.zParserElement.__init__�s���.2�f�f���<@������ ������"���"����m�?�@�@���%)��"�#�����
�26�&�&�����
� ���!������ ��� �-�-�d�D�$�?�?��� ���"���57����r/�warning_typec�:�|j�|��|S)aY
        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.parseString("x"))

        )r�append)r+rs  r-�suppress_warningzParserElement.suppress_warning�s ��	
��&�&�|�4�4�4��r/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  r-rzParserElement.copy�sZ��,�i��o�o���*�1�1�1�-����*�1�1�1�-����%�	D� ��!B�C�C�C�N��
r/)�listAllMatchesrU�list_all_matchesrc�6�|p|}|�||��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+rUrrs    r-�set_results_namezParserElement.set_results_names%��<(�;�+;���#�#�D�.�9�9�9r/c��|�|S|���}|�d��r|dd�}d}||_||_|S)Nrr�T)r�endswithr�r)r+rUr�newselfs    r-rzParserElement._setResultsName1sW���<��K��)�)�+�+���=�=����	"�����9�D�!�N�"���#1�1����r/T�
break_flagc���|r|j�d�fd�	}�|_||_n&t|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.
        Tc�P��ddl}|����||||��S�Nr)�pdb�	set_trace)r�r��	doActions�callPreParser�_parseMethods     �r-�breakerz(ParserElement.set_break.<locals>.breakerEs1����
�
�
��
�
����#�|�H�c�9�l�K�K�Kr/�_originalParseMethod�TT)�_parser �hasattr)r+rrrs   @r-�	set_breakzParserElement.set_break<sq����	?��;�L�
L�
L�
L�
L�
L�
L�,8�G�(�!�D�K�K��t�{�$:�;�;�
?�"�k�>����r/�fnsc��t|��dgkrg|_nhtd�|D����std���d�|D��|_|�d|�dd����|_|S)ao
        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�4K�|]}t|��V��dSr))�callable�rCr�s  r-�	<genexpr>z1ParserElement.set_parse_action.<locals>.<genexpr>�s(����2�2��x��|�|�2�2�2�2�2�2r/zparse actions must be callablec�,�g|]}t|����Sr9�r�r)s  r-rEz2ParserElement.set_parse_action.<locals>.<listcomp>�s��>�>�>�B��B���>�>�>r/�call_during_tryrF)r�r��allr��getr�r+r%�kwargss   r-�set_parse_actionzParserElement.set_parse_actionSs���V��9�9�����!�D����2�2�c�2�2�2�2�2�
B�� @�A�A�A�>�>�#�>�>�>�D��!'���!�6�:�:�o�u�#E�#E�"�"�D���r/c��|xjd�|D��z
c_|jp)|�d|�dd����|_|S)z�
        Add one or more parse actions to expression's list of parse actions. See :class:`set_parse_action`.

        See examples in :class:`copy`.
        c�,�g|]}t|����Sr9r,r)s  r-rEz2ParserElement.add_parse_action.<locals>.<listcomp>�s��;�;�;��[��_�_�;�;�;r/r-rF)r�rr/r0s   r-�add_parse_actionzParserElement.add_parse_action�sa��	
���;�;�s�;�;�;�;���!�/�
�6�:�:��v�z�z�/�5�A�A�4
�4
����r/c��|D]S}|j�t||�d��|�dd��������T|jp)|�d|�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�r	r�r/r)r+r%r1r�s    r-�
add_conditionzParserElement.add_condition�s���.�	�	�B���#�#�)���
�
�9� 5� 5�V�Z�Z��QV�=W�=W����
�
�
�
�"�/�
�6�:�:��v�z�z�/�5�A�A�4
�4
����r/r�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  r-�set_fail_actionzParserElement.set_fail_action�s������r/c��d}|r;d}|jD]/}		|�||��\}}d}�#t$rY�,wxYw|�;|S�NTF)r�r"r�)r+r�r��
exprsFound�e�dummys      r-�_skipIgnorableszParserElement._skipIgnorables�s����
��	��J��%�
�
���*�%&�X�X�h��%<�%<�
��U�%)�
�*��&�����D������	��
s�.�
;�;c���|jr|�||��}|jr;t|��}|j}||kr|||vr|dz
}||kr
|||v�|S�Nr)r�r?r��lenr�)r+r�r��instrlen�white_charss     r-�preParsezParserElement.preParse�s����	6��&�&�x��5�5�C���	��8�}�}�H��/�K���.�.�X�c�]�k�%A�%A��q�����.�.�X�c�]�k�%A�%A��
r/c�
�|gfSr)r9�r+r�r�rs    r-�	parseImplzParserElement.parseImpls���B�w�r/c��|Sr)r9�r+r�r��	tokenlists    r-�	postParsezParserElement.postParses���r/c
�
�d\}}}|j}t|��}	|s|j�r	|r|jr|�||��}
n|}
|
}|jjr|j�|||d��|js|
|	krA	|�||
|��\}}n?#t$rt||	|j|���wxYw|�||
|��\}}n�#t$rO}
|jj
r|j�
||||
d��|jr|�||||
���d}
~
wwxYw|r|jr|�||��}
n|}
|
}|js|
|	krA	|�||
|��\}}n?#t$rt||	|j|���wxYw|�||
|��\}}|�|||��}t||j|j|j���}|j�rM|s|j�rC|r�	|jD]y}	||||��}n$#t$r}td��}||�d}~wwxYw|�B||ur>t||j|jot+|tt,f��|j���}�zn�#t$r0}
|jj
r|j�
||||
d���d}
~
wwxYw|jD]y}	||||��}n$#t$r}td��}||�d}~wwxYw|�B||ur>t||j|jot+|tt,f��|j���}�z|r+|jjr|j�|||||d��||fS)N�rrrkF)�asList�modalz exception raised in parse action)r�rBr�rrErr�rrH�
IndexErrorr�r�	Exceptionr�rLr r�r�rr�r�
isinstancer�r�)r+r�r�rr�TRY�MATCH�FAIL�	debugging�len_instring�pre_loc�tokens_start�tokens�err�
ret_tokensr��parse_action_excr�s                  r-�
_parseNoCachezParserElement._parseNoCaches���#���U�D��J�	��8�}�}���&	K���&	K�
��"�D�$5�"�"�m�m�H�c�:�:�G�G�!�G�&���$�.�U��%�/�/��,��e�T�T�T��%�O��L�)@�)@�X�&*�n�n�X�w�	�&R�&R���V�V��%�X�X�X�,�X�|�T�[�RV�W�W�W�X����#'�.�.��7�I�"N�"N�K�C�����
�
�
��$�/���%�0�0� �,��c�5�����?�G��O�O�H�l�D�#�F�F�F������
�����
�� 1�
��-�-��#�6�6�����"�L��!�
K�W��%<�%<�T�"&�.�.��7�I�"N�"N�K�C����!�T�T�T�(��<���d�S�S�S�T����#�n�n�X�w�	�J�J���V�����#�v�6�6��!��D�$�T�_�D�DU�
�
�
�
���(	��(	�d�.@�(	��'
��"�.����<�%'�R��,�
�%K�%K�F�F��)�<�<�<�"0�1S�"T�"T�C�"%�+;�;�����<����"�-�&�
�2J�2J�)5� &� $� 0�'+��(M�$.�v��d�7K�$L�$L�&*�&7�*�*�*�J����!�����(�3���)�4�4�$�l�D�#�u���������
�����*���B�8�!#��H�l�J�!G�!G����%�8�8�8�,�-O�P�P��!�'7�7�����8�����)�f�J�.F�.F�%1�"� �,�#'�?�$I� *�6�L�$�3G� H� H�"&�"3�&�&�&�
���	�� �,�
��!�-�-��l�C��z�5�����J��s��AC�B�C�"C�C�
D7�(A
D2�2D7�,F�"F)�	J�
H,�+J�,
I
�6I�I
�
AJ�
K� +K�K�
K+�+
L�5L�Lr�r��raise_fatalc��	|�||d���dS#t$r|r�t|||j|���wxYw)NF�rr)r"r�r�r)r+r�r�r`s    r-�	try_parsezParserElement.try_parsense��	C��;�;�x���;�>�>�q�A�A��"�	C�	C�	C��
�� ��3���T�B�B�B�	C���s	� �%Ac�d�	|�||��dS#ttf$rYdSwxYwr;)rcr�rQ)r+r�r�s   r-�can_parse_nextzParserElement.can_parse_nextvsK��	��N�N�8�S�)�)�)��4���
�+�	�	�	��5�5�	���s��/�/�Forward�recursion_memosrc	�x�d\}}d\}}}	|||||f}
tj5tj}|�|
��}||jur�tj|xxdz
cc<	|�||||��}|�|
|d|d���|f��|cddd��S#t$r)}
|�|
|
j
|
j����d}
~
wwxYwtj|xxdz
cc<|jr<|j
jr0	|j
�|||d���n#t$rYnwxYwt!|t"��rF|jr=|j
jr1	|j
�||||d���n#t$rYnwxYw|�|d|d���|d}}}|jr>|j
jr2	|j
�|||||d���n#t$rYnwxYw||fcddd��S#1swxYwYdS)N)rrrNrrT)r�rk)r��packrat_cache_lock�
packrat_cacher/�not_in_cache�packrat_cache_statsr_r�r�ParseBaseExceptionr�r�r�rr�r�rSrRr�r�)r+r�r�rr�HIT�MISSrTrUrV�lookup�cache�value�pe�loc_�resultr�s                 r-�_parseCachezParserElement._parseCache�s6���	��T�"���U�D���#�|�Y�?��
�
-�(	$�(	$�!�/�E��I�I�f�%�%�E���*�*�*��1�$�7�7�7�1�<�7�7�7�!� �.�.�x��i��V�V�E��I�I�f�u�Q�x��q������#�&F�G�G�G� �(	$�(	$�(	$�(	$�(	$�(	$�(	$�(	$��*�����I�I�f�l�b�l�B�G�&<�=�=�=�����������1�#�6�6�6�!�;�6�6�6��:��$�"3�"=����)�3�3�H�c�4�SW�3�X�X�X�X��$�����������e�Y�/�/� ��z�!�d�&7�&B�!�!� �-�8�8� (�#�t�U�d�9������ )�!�!�!� �D�!�����K�',�Q�x��q������%��(�f�f���:��$�"3�"?����)�5�5�$�d�F�D�&�D�6������%�����������V�|�Q(	$�(	$�(	$�(	$�(	$�(	$�(	$�(	$�(	$�(	$�(	$�(	$����(	$�(	$�(	$�(	$�(	$�(	$s��AH/�%C�=8H/�
C5�$C0�0C5�50H/�&E�H/�
E�H/�E�+H/�>F�H/�
F+�(H/�*F+�+AH/�. H�H/�
H�H/�H�H/�/H3�6H3c���tj���dgttj��ztjdd�<tj���dSr)r�rj�clearrBrlrgr9r/r-�reset_cachezParserElement.reset_cache�s^���#�)�)�+�+�+�01�s�S��-�6
�6
�0
�
�)�!�!�!�,�	�%�+�+�-�-�-�-�-r/c��t���dt_dt_tjt_dS)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�ry�_left_recursion_enabled�_packratEnabledr_r"r9r/r-�disable_memoizationz!ParserElement.disable_memoization�s7��	�!�!�#�#�#�05�
�-�(-�
�%�,�:�
���r/)�force�cache_size_limitc�(�|rt���ntjrtd���|�t	��t_n3|dkrt
|���t_ntd|z���dt_dS)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�_UnboundedMemorg�_LRUMemo�NotImplementedErrorr{�rr~s  r-�enable_left_recursionz#ParserElement.enable_left_recursion�s���H�	S��-�-�/�/�/�/�
�
*�	S��Q�R�R�R��#�,:�,<�,<�M�)�)�
��
!�
!�,4�>N�,O�,O�,O�M�)�)�%�&7�:J�&J�K�K�K�04�
�-�-�-r/�r~c�<�|rt���ntjrtd���tjsXdt_|�t��t_nt|��t_tjt_	dSdS)af
        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|rrjrrvr"r�s  r-�enable_packratzParserElement.enable_packrats���@�	S��-�-�/�/�/�/�
�
2�	S��Q�R�R�R��,�	=�,0�M�)��'�.=�.?�.?�
�+�+�.8�9I�.J�.J�
�+�#0�#<�M� � � �
	=�	=r/)�parseAll�	parse_allr�c��|p|}t���|js|���|jD]}|����|js|���}	|�|d��\}}|rI|�||��}t��t��z}|�||��|S#t$r'}tjr�|�
d���d}~wwxYw)a6	
        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�ryr��
streamliner�r��
expandtabsr"rE�Empty�	StringEndrmr��with_traceback)	r+r�r�r�r=r�r[�ser�s	         r-�parse_stringzParserElement.parse_string4s!��Z�(����!�!�#�#�#���	��O�O�����!�	�	�A�
�L�L�N�N�N�N��}�	-��*�*�,�,�H�
	��+�+�h��2�2�K�C���
)��m�m�H�c�2�2���W�W�y�{�{�*���	�	�(�C�(�(�(��M��"�	/�	/�	/��/�
/���(�(��.�.�.�����	/���s�3A$C�
D
�#"D�D
)r��
maxMatches�max_matches�overlapr�r�c#�*K�t||��}|js|���|jD]}|����|js!t|�����}t|��}d}|j}	|j	}
t���d}	||kr�||kr�	|	||��}|
||d���\}
}|
|krS|dz
}|r%t|�
��||
d���|||
fV�|r|	||��}||kr|
}n$|dz
}n|
}n|dz}n#t$r|dz}YnwxYw||kr||k��dSdSdSdS#t$r'}tjr�|�d���d}~wwxYw)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�rr)r[�start�endN)�minr�r�r�r��strr�rBrEr"r��
resetCacher�rOr�rmr�r�)r+r�r�r�r�r�r=rCr��
preparseFn�parseFn�matches�preloc�nextLocr[�nextlocr�s                 r-�scan_stringzParserElement.scan_stringys.����N��[�1�1�
���	��O�O�����!�	�	�A�
�L�L�N�N�N�N��}�	2��8�}�}�/�/�1�1�H��x�=�=�����]�
��+��� � �"�"�"���"	/���/�/�g�
�&:�&:�)�'�Z��#�6�6�F�&-�g�h��U�&S�&S�&S�O�G�V���}�}��1��� ��!�.4�m�m�o�o�-3�+2�!"�!"����%�f�g�5�5�5�5�"�*�&0�j��3�&?�&?�G�&��}�}�&-��� #�q����")�C�C�$�q�j����/&�%�%�%� �1�*�C�C�C�%����	��/�/�g�
�&:�&:�&:�&:�/�/�&:�&:�/�/��8"�	/�	/�	/��/�
/���(�(��.�.�.�����	/���s=�/E!�<D8�AE!�8E
�E!�	E
�
E!�!
F�+"F
�
F�r�c��g}d}d|_	|�||���D]�\}}}|�|||���|r�t|t��r||���z
}nUt|t��r+t|t��s|�|��n|�|��|}��|�||d���d�|D��}d�	d�t|��D����S#t$r'}tj
r�|�d���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�Nc��g|]}|�|��Sr9r9�rC�os  r-rEz2ParserElement.transform_string.<locals>.<listcomp>�s��'�'�'��Q�'�1�'�'�'r/r~c�,�g|]}t|����Sr9�r�)rCr�s  r-rEz2ParserElement.transform_string.<locals>.<listcomp>�s��:�:�:�q�C��F�F�:�:�:r/)r�r�r	rSr r�rr#�extend�joinrrmr�r�r�)	r+r�r��out�lastEr�r�r=r�s	         r-�transform_stringzParserElement.transform_string�so��(������
�	/��+�+�H�E�+�B�B�	
�	
���1�a��
�
�8�E�!�G�,�-�-�-��&�!�!�\�2�2�&��q�y�y�{�{�*���#�A�x�0�0�&��A�x�9P�9P�&��
�
�1�
�
�
�
��
�
�1�
�
�
�����J�J�x����'�(�(�(�'�'�c�'�'�'�C��7�7�:�:�H�S�M�M�:�:�:�;�;�;��!�	/�	/�	/��/�
/���(�(��.�.�.�����	/���s�DD#�#
E�-"E�Ec���t||��}	td�|�|||���D����S#t$r'}tjr�|�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']
        c��g|]\}}}|��	Sr9r9)rCr�r�r=s    r-rEz/ParserElement.search_string.<locals>.<listcomp>s��V�V�V�w�q�!�Q��V�V�Vr/r�N)r�r r�rmr�r�r�)r+r�r�r�r�r�s      r-�
search_stringzParserElement.search_strings���8��[�1�1�
�		/��V�V�$�"2�"2�8�Z�u�"2�"U�"U�V�V�V���
��"�	/�	/�	/��/�
/���(�(��.�.�.�����	/���s�.A�
A2�"A-�-A2)�includeSeparators�maxsplit�include_separatorsc#�K�|p|}d}|�||���D] \}}}|||�V�|r
|dV�|}�!||d�V�dS)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	         r-rLzParserElement.split(s�����..�C�1C�����'�'��h�'�G�G�	�	�G�A�q�!��4��6�"�"�"�"� �
���d�
�
�
��D�D��t�u�u�o�����r/c�:�|turt|��St|t��r|�|��}t|t
��s4t
d�t|��j	�����t||g��S)ah
        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.
        �4Cannot combine element of type {} with ParserElement)�Ellipsis�_PendingSkiprSr#r�r�r�r�r�r2�And�r+�others  r-�__add__zParserElement.__add__Hs���6�H�����%�%�%��e�X�&�&�	4��,�,�U�3�3�E��%��/�/�	��F�M�M���K�K�(�����
�
�D�%�=�!�!�!r/c�:�|turt|��d��|zSt|t��r|�|��}t|t
��s4t
d�t|��j	�����||zS)zd
        Implementation of ``+`` operator when left operand is not a :class:`ParserElement`
        �	_skipped*r�)
r��SkipTorSr#r�r�r�r�r�r2r�s  r-�__radd__zParserElement.__radd__ps����H����6�$�<�<��,�,�t�3�3��e�X�&�&�	4��,�,�U�3�3�E��%��/�/�	��F�M�M���K�K�(�����
�
�t�|�r/c�&�t|t��r|�|��}t|t��s4t	d�t
|��j�����|t�	��z|zS)zX
        Implementation of ``-`` operator, returns :class:`And` with error stop
        r�)
rSr#r�r�r�r�r�r2r��
_ErrorStopr�s  r-�__sub__zParserElement.__sub__�s����e�X�&�&�	4��,�,�U�3�3�E��%��/�/�	��F�M�M���K�K�(�����
�
�c�n�n�&�&�&��.�.r/c���t|t��r|�|��}t|t��s4t	d�t
|��j�����||z
S)zd
        Implementation of ``-`` operator when left operand is not a :class:`ParserElement`
        r��rSr#r�r�r�r�r�r2r�s  r-�__rsub__zParserElement.__rsub__��x���e�X�&�&�	4��,�,�U�3�3�E��%��/�/�	��F�M�M���K�K�(�����
�
�t�|�r/c�&���|turd}nAt|t��r,|dd�tfkrd|dd�zdzdd�}t|t��r|d}}�nvt|t���r,td�|D����}|d	zdd�}|d�
d|df}t|dt��rY|d�Q|ddkrt	���S|ddkrt���S�|dzt	���zSt|dt��r&t|dt��r|\}}||z}nst
d
�d�d�|D���������t
d
�t|��j
�����|dkrtd���|dkrtd���||cxkrdkrnntg��S|rI��fd��|r5|dkr��|��z}nHt�g|z���|��z}n(�|��}n|dkr�}nt�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``
        )rNNrr�r)rkrc3�0K�|]}|tur|ndV��dSr))r�r�s  r-r*z(ParserElement.__mul__.<locals>.<genexpr>�s0����J�J�q�q��0�0�!�!�d�J�J�J�J�J�Jr/)NNz.cannot multiply ParserElement and ({}) objects�,c3�>K�|]}t|��jV��dSr)�r�r2)rC�items  r-r*z(ParserElement.__mul__.<locals>.<genexpr>�s+���� G� G���d���!4� G� G� G� G� G� Gr/z,cannot multiply ParserElement and {} objectsz/cannot multiply ParserElement by negative valuez@second tuple value must be greater or equal to first tuple valuec�j��|dkrt��|dz
��z��St���SrA)�Opt)�n�makeOptionalListr+s ��r-r�z/ParserElement.__mul__.<locals>.makeOptionalList�s;����q�5�5��t�&6�&6�q�1�u�&=�&=�=�>�>�>��t�9�9�$r/)
r�rS�tuple�int�
ZeroOrMore�	OneOrMorer�r�r�r�r2�
ValueErrorr�)r+r��minElements�optElementsr5r�s`    @r-�__mul__zParserElement.__mul__�s����(�H����E�E�
��u�
%�
%�	5�%����)��{�*B�*B��E�!�"�"�I�%��/��!��4�E��e�S�!�!�	�',�a��K�K�
��u�
%�
%�	��J�J�E�J�J�J�J�J�E��\�)�2�A�2�.�E��Q�x���E�!�H�
���%��(�C�(�(�
�U�1�X�-=���8�q�=�=�%�d�+�+�+���8�q�=�=�$�T�?�?�*��%��(�?�Z��-=�-=�=�=��E�!�H�c�*�*�
�z�%��(�C�/H�/H�
�+0�(��[��{�*����D�K�K���� G� G�� G� G� G�G�G�������>�E�E���K�K�(�����
���?�?��N�O�O�O���?�?��R���
��+�*�*�*�*��*�*�*�*�*��r�7�7�N��	0�
%�
%�
%�
%�
%�
%��
4��!�#�#��!1�!1�+�!>�!>�>�C�C��t�f�{�2�3�3�6F�6F�{�6S�6S�S�C�C�&�&�{�3�3����a�������4�&�;�.�/�/���
r/c�,�|�|��Sr))r�r�s  r-�__rmul__zParserElement.__rmul__�s���|�|�E�"�"�"r/c�>�|turt|d���St|t��r|�|��}t|t
��s4t
d�t|��j	�����t||g��S)zP
        Implementation of ``|`` operator - returns :class:`MatchFirst`
        T)�	must_skipr�)r�r�rSr#r�r�r�r�r�r2�
MatchFirstr�s  r-�__or__zParserElement.__or__�s����H������5�5�5�5��e�X�&�&�	4��,�,�U�3�3�E��%��/�/�	��F�M�M���K�K�(�����
�
�4��-�(�(�(r/c���t|t��r|�|��}t|t��s4t	d�t
|��j�����||zS)zd
        Implementation of ``|`` operator when left operand is not a :class:`ParserElement`
        r�r�r�s  r-�__ror__zParserElement.__ror__r�r/c�
�t|t��r|�|��}t|t��s4t	d�t
|��j�����t||g��S)zH
        Implementation of ``^`` operator - returns :class:`Or`
        r�)	rSr#r�r�r�r�r�r2�Orr�s  r-�__xor__zParserElement.__xor__s����e�X�&�&�	4��,�,�U�3�3�E��%��/�/�	��F�M�M���K�K�(�����
�
�4��-� � � r/c���t|t��r|�|��}t|t��s4t	d�t
|��j�����||zS)zd
        Implementation of ``^`` operator when left operand is not a :class:`ParserElement`
        r�r�r�s  r-�__rxor__zParserElement.__rxor__#r�r/c�
�t|t��r|�|��}t|t��s4t	d�t
|��j�����t||g��S)zJ
        Implementation of ``&`` operator - returns :class:`Each`
        r�)	rSr#r�r�r�r�r�r2�Eachr�s  r-�__and__zParserElement.__and__1s����e�X�&�&�	4��,�,�U�3�3�E��%��/�/�	��F�M�M���K�K�(�����
�
�T�5�M�"�"�"r/c���t|t��r|�|��}t|t��s4t	d�t
|��j�����||zS)zd
        Implementation of ``&`` operator when left operand is not a :class:`ParserElement`
        r�r�r�s  r-�__rand__zParserElement.__rand__?r�r/c� �t|��S)zL
        Implementation of ``~`` operator - returns :class:`NotAny`
        )�NotAny�r+s r-�
__invert__zParserElement.__invert__Ms���d�|�|�r/c
��	t|t��r|f}t|��n#t$r||f}YnwxYwt	|��dkr`td�|dd�t	|��dkr"d�t	|����nd�����|t
|dd���z}|S)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``.
        rkz,only 1 or 2 index arguments supported ({}{})Nrmz... [{}]r~)rSr#�iterr�rBr�r�)r+�keyr5s   r-�__getitem__zParserElement.__getitem__Ws���,	��#�x�(�(�
��f����I�I�I�I���	�	�	���*�C�C�C�	�����s�8�8�a�<�<��>�E�E�����G�C��H�H�q�L�L�Z�.�.�s�3�x�x�8�8�8�b�����
��U�3�r��r�7�^�^�#���
s�'*�;�;c�X�|�|�|��S|���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+rUs  r-�__call__zParserElement.__call__s,�����'�'��-�-�-��9�9�;�;�r/c� �t|��S)z�
        Suppresses the output of this :class:`ParserElement`; useful to keep punctuation from
        cluttering up returned output.
        )�Suppressr�s r-�suppresszParserElement.suppress�s��
��~�~�r/�	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+rs  r-�ignore_whitespacezParserElement.ignore_whitespace�s��#����r/c��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  r-�leave_whitespacezParserElement.leave_whitespace�s��$����r/�
copy_defaultsc�J�d|_t|��|_||_|S)z8
        Overrides the default whitespace chars
        T)r�r�r�r�)r+r�rs   r-�set_whitespace_charsz"ParserElement.set_whitespace_chars�s&��#����e�*�*���%2��"��r/c��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 r-�parse_with_tabszParserElement.parse_with_tabs�s����
��r/r�c�:�ddl}t|t��rt|��}t|t��r$||jvr|j�|��n9|j�t|�������|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�rSr#r�r�r	r)r+r�r�s   r-�ignorezParserElement.ignore�s��� 	�
�
�
��e�X�&�&�	$��U�O�O�E��e�X�&�&�	<��D�,�,�,�� �'�'��.�.�.����#�#�H�U�Z�Z�\�\�$:�$:�;�;�;��r/�start_action�success_action�exception_actionc�v�|�|pt|pt|pt��|_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�rr�)r+rrrs    r-�set_debug_actionszParserElement.set_debug_actions�sE��$!�-�-��7�7��;�;��?� ?�
�
���
��
��r/�flagc�f�|r'|�ttt��nd|_|S)a�
        Enable display of debugging messages while doing pattern matching.
        Set ``flag`` to ``True`` to enable, ``False`` to disable.

        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)rr�r�r�r�)r+rs  r-�	set_debugzParserElement.set_debug�sA��J�	��"�"�+�-�/�
�
�
�
��D�J��r/c�P�|j�|���|_|jSr))r��_generateDefaultNamer�s r-�default_namezParserElement.default_name(s(����$� $� 9� 9� ;� ;�D��� � r/c��dS)zg
        Child classes must define this method, which defines how the ``default_name`` is set.
        Nr9r�s r-rz"ParserElement._generateDefaultName.r�r/c�r�||_d|jz|_tjr|���|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�rUrrOrfrr�s  r-�set_namezParserElement.set_name4s9�����!�D�I�-����5�	��N�N�����r/c�,�|j�|jn|jSr))r�rr�s r-rUzParserElement.nameAs��#'�/�"=�t���4�CT�Tr/c��|jSr)�rUr�s r-�__str__zParserElement.__str__Fs
���y�r/c� �t|��Sr)r�r�s r-�__repr__zParserElement.__repr__Is���4�y�y�r/c�"�d|_d|_|S�NT)r�r�r�s r-r�zParserElement.streamlineLs����� ����r/c��gSr)r9r�s r-�recursezParserElement.recurseQ����	r/c�z�|dd�|gz}|���D]}|�|���dSr))r&�_checkRecursion�r+�parseElementList�subRecCheckListr=s    r-r)zParserElement._checkRecursionTsO��*�1�1�1�-���6�������	/�	/�A�
���o�.�.�.�.�	/�	/r/c�0�|�g��dS)zj
        Check defined expressions for valid structure, check for infinite recursive definitions.
        N)r))r+�
validateTraces  r-�validatezParserElement.validateYs��	
���R� � � � � r/�utf-8�file_or_filename�encodingc�h�|p|}	|���}nN#t$rAt|d|���5}|���}ddd��n#1swxYwYYnwxYw	|�||��S#t$r'}t
jr�|�d���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�r2N)�read�AttributeError�openr�rmr�r�r�)r+r1r2r�r��
file_contents�fr�s        r-�
parse_filezParserElement.parse_file_s���(�y��	)�,�1�1�3�3�M�M���	)�	)�	)��&��h�?�?�?�
)�1� !�����
�
)�
)�
)�
)�
)�
)�
)�
)�
)�
)�
)����
)�
)�
)�
)���	)����	/��$�$�]�H�=�=�=��!�	/�	/�	/��/�
/���(�(��.�.�.�����	/���sJ��A&�A�A&�A	�A&�A	� A&�%A&�*B�
B1�
"B,�,B1c���||urdSt|t��r|�|d���St|t��r t	|��t	|��kSdS)NT�r�F)rSr#r�r��varsr�s  r-�__eq__zParserElement.__eq__{sf���5�=�=��4�
��x�
(�
(�	-��<�<���<�6�6�6�
��}�
-�
-�	-���:�:��e���,�,��ur/c� �t|��Sr))�idr�s r-�__hash__zParserElement.__hash__�s
���$�x�x�r/�test_stringc�z�|o|}	|�t|��|���dS#t$rYdSwxYw)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")
        r=TF)r�r�rm)r+rCr�r�s    r-r�zParserElement.matches�s[�� �)�	��	����c�+�.�.�(��C�C�C��4��!�	�	�	��5�5�	���s�$,�
:�:�#)r��fullDump�printResults�failureTestsrL�tests�comment�	full_dump�
print_results�
failure_tests�
post_parse�file�with_line_numbersrFrGrHrLc

�V	��ddlm}|
o|}
|o|}|o|}|
p|}
|p|}t|t��rFt	|��j��fd�|������D��}t|t��rt|��}|�tj
}|j}g}g}d}td���td�����t��}d}|D�]�}|�|�|d	��s|r/|s-|�|	r|�|��n|���L|s�O|rdd�|��znd
|	r|�|��n|g}g}	|�|�|����}|�||
���}|o|
}|��	|||��}|�`t|t.��r(|�|�����nJ|�t3|����n'|�|������n�#t4$ru}|�|�|�����|�d
�|jt	|��j|����Yd}~�nxd}~wwxYw|�|�|������nE#t:$r�}t|t<��rdnd
}|�|�����|�dt3|��z��t@j!r,|�"tGj$|j%����|o|
}|}Yd}~n�d}~wt4$r�}|�d�t	|��j|����t@j!r,|�"tGj$|j%����|o|
}|}Yd}~nd}~wwxYw|�d
��|r|d�|����|�||f�����||fS)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_testc�&��g|]
}�|����Sr9r9)rC�	test_line�
line_strips  �r-rEz+ParserElement.run_tests.<locals>.<listcomp>s#���X�X�X�y�Z�Z�	�*�*�X�X�Xr/NT�\n�
uFr~r=)�fullz{} failed: {}: {}z(FATAL)zFAIL: zFAIL-EXCEPTION: {}: {})&�testingrRrSr#r��strip�rstrip�
splitlines�Literal�sys�stdout�writer5�replace_withr
�
quoted_stringr�r	rPr�r��lstripr�r �dumpr�rRr�r2rmr��explainr�r�r�r��	format_tbr�)r+rIr�rJrKrLrMrNrOrPr�rFrGrHrLrR�print_�
allResults�comments�success�NL�BOMr�r�ru�pp_valuer=rsr�r�rUs                              @r-�	run_testszParserElement.run_tests�s����`	,�+�+�+�+�+��)�	���)�	��#�5�
��#�4�}���+��	��e�X�&�&�	Y��e���*�J�X�X�X�X�E�L�L�N�N�<U�<U�<W�<W�X�X�X�E��g�x�(�(�	'��g�&�&�G��<��:�D�����
�����
�U�^�^�
,�
,�\�$�-?�-?�
@�
@�
G�
G�
�
V�
V�����9	+�9	+�A��"�w���q�%�'@�'@�"�H�"�UV�"����;L�S�N�4�4�Q�7�7�7�RS������
��.6�>��t�y�y��*�*�*�*�B�7H�O��0�0��3�3�3�a��C��H�&
;��'�'�����
�
�6�6���*�*�1��*�A�A�� "�6�,�&6���(��#,�9�Q��#7�#7��#�/�)�(�L�A�A�:� #�
�
�8�=�=�?�?� ;� ;� ;� ;� #�
�
�3�x�=�=� 9� 9� 9� 9��J�J�v�{�{�}�}�5�5�5���$�����
�
�6�;�;�H�;�#=�#=�>�>�>��
�
�/�6�6� )� 2�D��G�G�4D�a��������������������J�J�v�{�{��{�9�9�:�:�:�:��E&�
�
�
�%/��4G�%H�%H�P�	�	�b���
�
�2�:�:�<�<�(�(�(��
�
�8�c�"�g�g�-�.�.�.� �3�F��J�J�y�2�2�3C�D�D�E�E�E�!�2�l��������������
�
�
��
�
�3�:�:�4��9�9�;M�s�S�S�T�T�T� �3�G��J�J�y�2�3�3D�E�E�F�F�F�!�2�l�������������
����6
�J�J�r�N�N�N��
'���t�y�y��~�~�&�&�&����q�&�k�*�*�*�*��
�"�"s@�?L�BI'�'
K&�1A*K!�!K&�
Q�B#O�
Q�A9Q�Qr$�output_html�vertical�show_results_names�show_groupsc��	ddlm}m}n"#t$r}t	d��|�d}~wwxYw|���||||||���}	t
|ttf��rKt|dd���5}
|
�
||	����ddd��dS#1swxYwYdS|�
||	����dS)	a�
        Create a railroad diagram for the parser.

        Parameters:
        - output_html (str or file-like object) - output target for generated
          diagram HTML
        - vertical (int) - threshold for formatting multiple alternatives vertically
          instead of horizontally (default=3)
        - show_results_names - bool flag whether diagram should show annotations for
          defined results names
        - show_groups - bool flag whether groups should be highlighted with an unlabeled surrounding box
        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)rprqrr�diagram_kwargs�wr0r5)�diagramrtru�ImportErrorrRr�rSr�rr8r`)r+rorprqrrr1rtru�ie�railroad�	diag_files           r-�create_diagramzParserElement.create_diagramasd��.	�>�>�>�>�>�>�>�>�>���	�	�	��_����
�����	����
	
�������;���1�#�!�
�
�
���k�C��;�/�/�	:��k�3��9�9�9�
<�Y���� 0� 0�� :� :�;�;�;�
<�
<�
<�
<�
<�
<�
<�
<�
<�
<�
<�
<����
<�
<�
<�
<�
<�
<�
���.�.�x�8�8�9�9�9�9�9s"��
*�%�*�?B+�+B/�2B/�F�rXr��Tr!r^r))r�)r�r�rXr�)r0F)TrETTFNNF)r$FF)�r2r7r8rGr�r�r�r�rr�r�r�r��staticmethodr�r�rr�r.rjr
rrrr$�ParseActionr2r5�ParseConditionr7�ParseFailActionr9r?rErHrLrr�r r_rcrer�recursion_lockrg�DictrrRrjrirlrvr"ryr|r{r}r�r�r��_MAX_INTrr�r�r�rLr�r�r�r�r�r�r�r�r�r�r�r�r��__iter__r�r�r�rrrr	rr
r�r�r�rr�propertyrrrrrUr r"r�rr&r)r/rr
r;r?rBr�r	rrnr}�setDefaultWhitespaceChars�inlineLiteralsUsing�setResultsName�setBreak�setParseAction�addParseAction�addCondition�
setFailAction�tryParse�canParseNextr��enableLeftRecursion�
enablePackrat�parseString�
scanString�searchString�transformString�setWhitespaceChars�
parseWithTabs�setDebugActions�setDebug�defaultName�setName�	parseFile�runTests�ignoreWhitespace�leaveWhitespacer9r/r-r�r��sT
�������3�3�(���(�(�(�$���$�$�$�15�����.�5�5�5��-�C�-�D�-�-�-��\�-�(�0�4�0�D�0�0�0��\�0�*:�:�:�:�:�z�:�:�:�
8�8��8�8�8�8�8�[��_����� ����<38�:�SX�:�:�:��:�+/�:�LP�:�	�:�:�:�:�B	�	�	�	���D��O�����.T�[�T��T�T�T�T�l
�[�
��
�
�
�
�!�.�!��!�!�!�!�F�/��o����� ���
�
�
��������
;?�d�d�	�s�L� �	!�d�d�d�d�LC�C�#�C�C�C�d�C�s�C�C�C�C��s����������U�W�W�N�	��V�[�
�c�9�d�"�#�U�3��l�I�6M�0N�+N�%O�O�����	��������a�&��
;?�.$�.$�	�s�L� �	!�.$�.$�.$�.$�`�F��.�.�.��\�.��O�#���;�;�;��\�;��15�-5�@E�-5�-5�-5� �/�#�.�-5�	
�-5�-5�-5��\�-5�^�)=�U�)=�)=�)=��)=�d�)=�t�)=�)=�)=��\�)=�X05�C�JO�C�C�C��C�(,�C�CG�C�	�C�C�C�C�P$��	W/��"�W/�W/�W/��W/��W/��	W/��
W/��W/�
�5��s�C�/�0�$��<�	=�W/�W/�W/�W/�r@E�,/�,/�,/��,/��,/��,/�,/�,/�,/�b$�&/�
�"�
&/�&/�&/��&/��&/�
�&/��
&/�
�&/�&/�&/�&/�V!�#(�	� �
�������!�	�
�3��d�?�	#�����@&"�&"�&"�&"�P����"/�/�/�/�����T�T�T�T�l#�#�#�#�)�)�)�)�"����!�!�!�!�����#�#�#�#����������H�&�&�&�P��S��O�����(������4��?�����	�	�$�	�/�	�	�	�	�BG�	�	��3�s�8�S�=�)�	�:>�	�	�	�	�	�	���������8�&��+��/�	�

�����4-�-�d�-�o�-�-�-�-�^�!�c�!�!�!��X�!�
����^��
�S��_������U�c�U�U�U��X�U��������#���������
��/�2�����/�/�/�
!�!�!�!�!� ��	/��
/�/�/���T�6� 1�2�/��/��	/��
/�
�/�/�/�/�8������37��LP������+/��EI��	
�����4�@C��"�#�9=�(,�"'�A#���!�"�8<�!A#�A#�A#��S�$�s�)�^�$�A#��A#������';�!<�=�	A#�
�A#��
A#��A#��c�<�0�#�5�6�A#��o�f�%�A#� �A#��A#��A#��A#��A#� �S�,�/��4�5�!A#�"
�t�T�%��U�<��+B�%C� C�D�E�E�	F�#A#�A#�A#�A#�L�#(�!�,:�,:��6�4��,�-�,:��,:�!�	,:�
�,:�
�,:�,:�,:�,:�\!=��/��%�N��H�%�N�%�N� �L�#�M��H�!�L��J�/��"�M��K��J� �L�&�O�-��#�M�'�O��H��K��G��I��H�(��&�O�O�Or/c�D��eZdZddedef�fd�
Zd�Zdd�Zd	�Zd
�Z	�xZ
S)
r�Fr�r�c�d��t�����||_||_dSr))�superr.�anchorr�)r+r�r�r�s   �r-r.z_PendingSkip.__init__�s+���
�����������"����r/c�p�t|jt��z���dd��S)Nr��...)r�r�r��replacer�s r-rz!_PendingSkip._generateDefaultName�s+���4�;����(�)�)�1�1�'�5�A�A�Ar/rXr�c���t|���d��d��}�jrNd�}�fd�}�j|���|��z|���|��z|zS�j|z|zS)Nr�r�c��|jr|j���dgkr|d=|�dd��dSdS)Nr~r�_skipped)r�r��pop)r�s r-r�z'_PendingSkip.__add__.<locals>.must_skip�sP���z�,�Q�Z�%7�%7�%9�%9�b�T�%A�%A��!���E�E�*�d�+�+�+�+�+�&B�%Ar/c���|j���dd�dgkr4|�d��dt�j��zdz|d<dSdS)Nr�r~r�z	missing <�>)r�r�r��reprr�)r�r+s �r-�	show_skipz'_PendingSkip.__add__.<locals>.show_skip�sb����:�%�%�'�'����,���4�4��E�E�*�%�%�%�$/�$�t�{�2C�2C�$C�c�$I�A�j�M�M�M�5�4r/)r�rr�r�r5)r+r��skipperr�r�s`    r-r�z_PendingSkip.__add__�s����/�&��-�-�(�(��/�/��<�<���>�	�
,�
,�
,�

J�
J�
J�
J�
J���g�g�i�i�8�8��C�C�C��'�)�)�,�,�Y�7�7�8���
�
�{�W�$�u�,�,r/c��|jSr))r�r�s r-r"z_PendingSkip.__repr__�s����r/c� �td���)NzBuse of `...` expression without following SkipTo target expression)rR)r+r�s  r-rHz_PendingSkip.parseImpl�s���P�
�
�	
r/r~r)r2r7r8r�rr.rr�r"rH�
__classcell__�r�s@r-r�r��s��������#�#�]�#�t�#�#�#�#�#�#�
B�B�B�-�-�-�-�* � � �
�
�
�
�
�
�
r/r�c�(��eZdZdZ�fd�Zd�Z�xZS)�TokenzYAbstract :class:`ParserElement` subclass, for defining atomic
    matching patterns.
    c�L��t���d���dS)NF�r��r�r.�r+r�s �r-r.zToken.__init__�s$���
�����%��(�(�(�(�(r/c�*�t|��jSr)r�r�s r-rzToken._generateDefaultName�s���D�z�z�"�"r/)r2r7r8rGr.rr�r�s@r-r�r��sQ���������)�)�)�)�)�#�#�#�#�#�#�#r/r�c�"��eZdZdZ�fd�Z�xZS)r�z,
    An empty token, will always match.
    c�d��t�����d|_d|_dSr;�r�r.r�rr�s �r-r.zEmpty.__init__��/���
��������"���"����r/)r2r7r8rGr.r�r�s@r-r�r��sB���������#�#�#�#�#�#�#�#�#r/r�c�*��eZdZdZ�fd�Zdd�Z�xZS)�NoMatchz(
    A token that will never match.
    c�r��t�����d|_d|_d|_dS)NTFzUnmatchable token)r�r.r�rrr�s �r-r.zNoMatch.__init__�s4���
��������"���"���)����r/Tc�0�t|||j|���r))r�rrGs    r-rHzNoMatch.parseImpl�s���X�s�D�K��>�>�>r/r��r2r7r8rGr.rHr�r�s@r-r�r��sV���������*�*�*�*�*�?�?�?�?�?�?�?�?r/r�c�B��eZdZdZd
dd�dedef�fd�Zd�Zdd	�Z�xZS)r]a�
    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`.
    r~��matchString�match_stringr�c�z��t�����|p|}||_t|��|_	|d|_n#t$rtd���wxYwd|jz|_	d|_
d|_|jdkr$t|��turt|_dSdSdS)Nrz2null string passed to Literal; use Empty() insteadrFr)r�r.�matchrB�matchLen�firstMatchCharrQr�rUrr�rr�r]�_SingleCharLiteralr��r+r�r�r�s   �r-r.zLiteral.__init__	s����
��������"�2�l��!��
��L�)�)��
�	S�".�q�/�D�����	S�	S�	S��Q�R�R�R�	S����!�D�I�-���#���"����=�A���$�t�*�*��"7�"7�/�D�N�N�N���"7�"7s�
A�A*c�*�t|j��Sr)�r�r�r�s r-rzLiteral._generateDefaultName	����D�J���r/Tc��|||jkr,|�|j|��r||jz|jfSt	|||j|���r))r�rAr�r�r�rrGs    r-rHzLiteral.parseImpl 	s\���C�=�D�/�/�/�H�4G�4G��J��5
�5
�/����&��
�2�2��X�s�D�K��>�>�>r/�r~r�)	r2r7r8rGr�r.rrHr�r�s@r-r]r]�s��������
�
�0�R�0�0�0�S�0�s�0�0�0�0�0�0�$ � � �?�?�?�?�?�?�?�?r/r]c��eZdZdd�ZdS)r�Tc�j�|||jkr|dz|jfSt|||j|���rA)r�r�r�rrGs    r-rHz_SingleCharLiteral.parseImpl)	s;���C�=�D�/�/�/���7�D�J�&�&��X�s�D�K��>�>�>r/Nr��r2r7r8rHr9r/r-r�r�(	s(������?�?�?�?�?�?r/r�c
���eZdZdZedzZ			dddd�dedejed	e	d
edejef
�fd�Z
d
�Zdd�Ze
dd���ZeZ�xZS)�Keyworda�
    Token to exactly match a specified string as a keyword, that is,
    it must be immediately followed by a non-keyword character.  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:

    - ``identChars`` 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_$r~NF�r��
identCharsr��ident_chars�caselessr�r�c���t�����|p|}|�tj}|p|}||_t|��|_	|d|_n#t$rtd���wxYwd�
t|��j|j
��|_d|_d|_||_|r-|���|_|���}t)|��|_dS)Nrz2null string passed to Keyword; use Empty() insteadzExpected {} {}F)r�r.r��DEFAULT_KEYWORD_CHARSr�rBr�r�rQr�r�r�r2rUrr�rr��upper�
caselessmatchr�r�)r+r�r�r�r�r�r�s      �r-r.zKeyword.__init__O	s
���	���������.�;�
��� �6�J�"�2�l��!��
��L�)�)��
�	S�".�q�/�D�����	S�	S�	S��Q�R�R�R�	S����&�-�-�d�4�j�j�.A�4�9�M�M���#���"��� ��
��	,�!-�!3�!3�!5�!5�D��#�)�)�+�+�J��j�/�/����s�
A"�"A<c�*�t|j��Sr)r�r�s r-rzKeyword._generateDefaultNamel	r�r/Tc�,�|j}|}|jr�||||jz����|jkr�|dks$||dz
���|jvre|t
|��|jz
ks)|||jz���|jvr||jz|jfS|dz
}||jz}n�|dz
}|dz
}n�|||jkr|jdks|�	|j|��ru|dks||dz
|jvrS|t
|��|jz
ks|||jz|jvr||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)rr�r�r�r�r�rBr�r�rAr�)r+r�r�rr�errlocs      r-rHzKeyword.parseImplo	s���������=�'	%���c�D�M�1�1�2�8�8�:�:�d�>P�P�P��!�8�8�x��a��0�6�6�8�8���O�O��s�8�}�}�t�}�<�<�<�#�C�$�-�$7�8�>�>�@�@���W�W�"�T�]�2�D�J�>�>��"S�S��!$�t�}�!4����W�W�F� �1�W�F��
��
��!4�4�4��M�Q�&�&��&�&�t�z�3�7�7�'��!�8�8�x��a��0���G�G��s�8�}�}�t�}�<�<�<�#�C�$�-�$7�8���O�O�"�T�]�2�D�J�>�>��U���"%�t�}�!4����W�W�F� �1�W�F��X�v�v�t�<�<�<r/rXc��|t_dS)zX
        Overrides the default characters used by :class:`Keyword` expressions.
        N)r�r�)r�s r-�set_default_keyword_charsz!Keyword.set_default_keyword_chars�	s��
).��%�%�%r/)r~NFr�r^)r2r7r8rG�	alphanumsr�r�r�r�rr.rrHr�r��setDefaultKeywordCharsr�r�s@r-r�r�2	s����������4&��,���,0��	*��+/�*�*�*��*��_�S�)�*��	*��
*��O�C�(�*�*�*�*�*�*�: � � �-=�-=�-=�-=�^�.�.�.��\�.�7�����r/r�c�<��eZdZdZd	dd�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`.)
    r~r�r�r�c���|p|}t���|�����||_d|jz|_dS)Nr)r�r.r��returnStringrUrr�s   �r-r.zCaselessLiteral.__init__�	sK���"�2�l��
������+�+�-�-�.�.�.�(���!�D�I�-����r/Tc��||||jz����|jkr||jz|jfSt	|||j|���r))r�r�r�r�r�rrGs    r-rHzCaselessLiteral.parseImpl�	sW���C�#��
�-�-�.�4�4�6�6�$�*�D�D����&��(9�9�9��X�s�D�K��>�>�>r/r�r�)r2r7r8rGr�r.rHr�r�s@r-r�r��	sz���������.�R�.�.�.�S�.�s�.�.�.�.�.�.�?�?�?�?�?�?�?�?r/r�c�n��eZdZdZ		d
ddd�dedejededejef�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`.)
    r~Nr�r�r�r�r�c�`��|p|}|p|}t���||d���dS)NT)r�r�)r+r�r�r�r�r�s     �r-r.zCaselessKeyword.__init__�	s>��� �.�;�
�"�2�l��
������z�D��A�A�A�A�Ar/)r~N)	r2r7r8rGr�r�r�r.r�r�s@r-r�r��	s��������	�	��,0�
B�
�+/�
B�
B�
B��
B��_�S�)�
B�
�
B��O�C�(�
B�
B�
B�
B�
B�
B�
B�
B�
B�
Br/r�c�J��eZdZdZ	d
ddd�dededef�fd	�Zd
�Zdd�Z�xZ	S)�
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']})
    NrF)�
maxMismatchesr�r��max_mismatchesr�c����|�|n|}t�����||_||_d�|j|j��|_||_d|_d|_dS)Nz(Expected {!r} (with up to {} mismatches)F)	r�r.r�r�r�rr�rr�)r+r�r�r�r�r�s     �r-r.zCloseMatch.__init__�	sz���+9�*D���-�
�
��������(���*���@�G�G���t�1�
�
���!��
�"���#����r/c�\�d�t|��j|j��S)Nz{}:{!r})r�r�r2r�r�s r-rzCloseMatch._generateDefaultName
s$������T�
�
� 3�T�5F�G�G�Gr/Tc�*�|}t|��}|t|j��z}||kr�|j}d}g}	|j}
tt	|||�|����D]i\}}|\}}
|jr(|���|
���}
}||
kr*|	�|��t|	��|
krn/�j||zdz}t|||�g��}||d<|	|d<||fSt|||j
|���)Nrr�original�
mismatches)rBr�r��	enumerate�zipr�r�r	r r�r)r+r�r�rr�rC�maxlocr��match_stringlocr�r��s_m�src�mat�resultss               r-rHzCloseMatch.parseImpl
s>�����x�=�=����T�.�/�/�/���X����,�L��O��J� �.�M�(1��H�S��Z�(�,�7�7�)�)�
$�
$�$������S��=�8�"�y�y�{�{�C�I�I�K�K��C��#�:�:��%�%�o�6�6�6��:����6�6�����o�-��1��&���s��(;�'<�=�=��&2��
�#�(2���%��G�|�#��X�s�D�K��>�>�>r/r)r��
r2r7r8rGr�r�r.rrHr�r�s@r-r�r��	s�������� � �J#�$�
��
$�$�$��$��$�
�$�$�$�$�$�$�&H�H�H�?�?�?�?�?�?�?�?r/r�c����eZdZdZ							dddddd�ded	ejed
ededed
edejedejedejededejef�fd�Z	d�Z
dd�Z�xZS)�Worda8Token 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=",")
    r~NrrF)�	initChars�	bodyChars�	asKeyword�excludeChars�
init_chars�
body_charsr��max�exact�
as_keyword�
exclude_charsrrr	r
c�~��|p|}|	p|}	|
p|}
|p|}t�����|s4td�t	|��j�����t
|��}||_|r(t
|��}||z}|	rt
|	��|z
}	d�t|����|_
|	r<d�t|	����|_t
|	��|_n;d�t|����|_t
|��|_|dk|_
|dkrtd���||_|dkr||_nt |_|dkr||_||_d|jz|_d|_|
|_d|j|jzv�r�|dk�r�|dk�r�|j|jkrr|dkrd	}n;|dkrd}n2d
�|j|jt krdn|j��}d�t+|j��|��|_n�t/|j��dkrg|dkrd}nd
�|dz
��}d�t1j|j
��t+|j��|��|_nj|dkrd}n!|dkrd}nd
�|dz
��}d�t+|j��t+|j��|��|_|jrd|jzdz|_	t1j|j��|_|jj|_t:|_dS#t0j$rd|_YdSwxYwdSdSdS)Nz,invalid {}, initChars cannot be empty stringr~rrzUcannot specify a minimum length < 1; use Opt(Word()) if zero-length word is permittedrFr��+�	{{{},{}}}z[{}]{}rz{{0,{}}}z{}[{}]{}rkz
[{}][{}]{}z\b) r�r.r�r�r�r2r�rr��sorted�
initCharsOrig�
bodyCharsOrigr�maxSpecified�minLen�maxLenr�rUrrr	r�reStringrB�re�escape�compiler��re_match�
_WordRegexr��error)r+rrr�r
rrrrrr	r
�repeatr�s             �r-r.z
Word.__init__v
s�����+��	��+��	��+��	�#�4�}��
���������	��>�E�E���J�J�'�����
��	�N�N�	�"����	:��|�,�,�L���%�I��
:��	�N�N�\�9�	��W�W�V�I�%6�%6�7�7����	,�!#����	�):�):�!;�!;�D�� ��^�^�D�N�N�!#����	�):�):�!;�!;�D�� ��^�^�D�N��!�G�����7�7��g���
������7�7��D�K�K�"�D�K��1�9�9��D�K��D�K�!�D�I�-���"���"����d�n�t�~�5�5�5�3�!�8�8��QR�
�
��~���/�/��!�8�8� �F�F��A�X�X��F�F�(�/�/���4�;�(�+B�+B�R�R�����F�!)���.�t�~�>�>��!�!��
�
��T�^�$�$��)�)��!�8�8� �F�F�'�.�.�s�Q�w�7�7�F� *� 1� 1��I�d�0�1�1�.�t�~�>�>��!�!��
�
��!�8�8� �F�F��A�X�X��F�F�'�.�.�s�Q�w�7�7�F� ,� 3� 3�.�t�~�>�>�.�t�~�>�>��!�!��
�
�~�
>� %��
� 5�� =��
�
,��*�T�]�3�3���!%��
��
�!+������	�8�
�
�
�������
����S6�5�8�8�
�
s�N�N6�5N6c�2�d�}|j|jkr3d�||j��||j����}n#d�||j����}|jdks|jt
kr�|j|jkr2|jdkr
|dd�S|d�|j��zS|jt
kr|d�|j��zS|d�|j|j��zS|S)	Nc�r�d}t|d���}t|��|kr|d|dz
�dzS|S)N�F)�	re_escaper$r�)rrB)r��max_repr_lens  r-�
charsAsStrz-Word._generateDefaultName.<locals>.charsAsStr�
sJ���L�*�1��>�>�>�A��1�v�v��$�$��+�<�!�+�+�,�u�4�4��r/z
W:({}, {})zW:({})rrkz{{{}}}z
{{{},...}}r)rrr�rrr�)r+r'�bases   r-rzWord._generateDefaultName�
s��	�	�	��>�T�^�+�+��&�&��
�4�>�*�*�J�J�t�~�,F�,F���D�D��?�?�:�:�d�n�#=�#=�>�>�D��;��?�?�d�k�X�5�5��{�d�k�)�)��;�!�#�#�����8�O��(�/�/�$�+�">�">�>�>����(�(��l�1�1�$�+�>�>�>�>��k�0�0���d�k�J�J�J�J��r/Tc��|||jvrt|||j|���|}|dz
}t|��}|j}||jz}t
||��}||kr|||vr|dz
}||kr
|||v�d}||z
|jkrd}nF|jr||kr
|||vrd}n,|j	r%|dkr
||dz
|vs||kr|||vrd}|rt|||j|���||||�fS)NrFTr)
rr�rrBrrr�rrr	)	r+r�r�rr�rC�	bodycharsr��throwExceptions	         r-rHzWord.parseImpls[���C�=���.�.� ��3���T�B�B�B����q����x�=�=���N�	����$���V�X�&�&���F�l�l�x��}�	�9�9��1�H�C��F�l�l�x��}�	�9�9�����;���$�$�!�N�N�
�
�		&�3��>�>�h�s�m�y�6P�6P�!�N�N�
�^�	&���	�	��U�Q�Y�'�9�4�4���>�>��S�M�Y�.�.�!%���	C� ��3���T�B�B�B��H�U�3�Y�'�'�'r/)r~NrrrFNr�)
r2r7r8rGr�r�r�r�rr.rrHr�r�s@r-rr5
sC�������>�>�D�+/���� �.2�o,�+/�*.��-1�o,�o,�o,��o,��O�C�(�o,��	o,�
�o,��
o,��o,���s�+�o,��?�3�'�o,��?�3�'�o,��o,��o�c�*�o,�o,�o,�o,�o,�o,�b���:(�(�(�(�(�(�(�(r/rc��eZdZdd�ZdS)rTc��|�||��}|st|||j|���|���}||���fSr))rr�rr��group)r+r�r�rrus     r-rHz_WordRegex.parseImpl&sT�����x��-�-���	C� ��3���T�B�B�B��j�j�l�l���F�L�L�N�N�"�"r/Nr�r�r9r/r-rr%s(������#�#�#�#�#�#r/rc
�r��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)r	r
�charsetrrr	r
c�Z��|p|}|p|}t���|d||���d�t|j����|_|rd�|j��|_t
j|j��|_|jj|_	dS)Nr)rr	r
z[{}]z\b{}\b)
r�r.r�rrrrrr�r)r+r1rrr	r
r�s      �r-r.z
Char.__init__5s�����+��	�#�4�}��
������1�	��	�	
�	
�	
��
�
�&@���&P�&P�Q�Q��
��	<�%�,�,�T�]�;�;�D�M��*�T�]�+�+�����
��
�
�
r/)FN)
r2r7r8rGr�rr�r�r.r�r�s@r-r0r0/s����������!�.2�	&� �-1�&�&�&��&��&���s�+�	&��
&��o�c�*�&�&�&�&�&�&�&�&�&�&r/r0c����eZdZdZ			dddd�dedeejefde	de	d	e	d
e	f�fd�Z
ed���Zed
���Zed���Z
d�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]'))
    rF)�asGroupList�asMatch�pattern�flags�
as_group_list�as_matchr5r6c���t�����|p|}|p|}t|t��r.|st	d���d|_|x|_|_||_nQt|d��r2t|d��r"||_|jx|_|_||_ntd���d|jz|_d|_
||_||_|jr|j|_|jr|j|_dSdS)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() insteadNr7r�zCRegex may only be constructed with a string or a compiled RE objectrF)r�r.rSr#r��_rerr7r8r#r�rUrrr5r6�parseImplAsGroupListrH�parseImplAsMatch)r+r7r8r9r:r5r6r�s       �r-r.zRegex.__init__cs/���	��������!�2�]���%�X���g�x�(�(�	��
U� �!S�T�T�T��D�H�+2�2�D�M�D�L��D�J�J�
�W�i�
(�
(�	�W�W�g�-F�-F�	��D�H�+2�?�:�D�L�4�=��D�J�J��U���
�"�D�I�-���"���&��������	7�!�6�D�N��<�	3�!�2�D�N�N�N�	3�	3r/c���|jr|jS	tj|j|j��S#tj$r(t
d�|j�����wxYw)Nz&invalid pattern ({!r}) passed to Regex)r<rrr7r8r r�r�r�s r-rzRegex.re�sp���8�	��8�O�
��z�$�,��
�;�;�;���8�
�
�
� �<�C�C�D�L�Q�Q����
���s	�/�7A&c��|jjSr))rr�r�s r-rzRegex.re_match�s���w�}�r/c�0�|�d��duS�Nr~)rr�s r-r�zRegex.mayReturnEmpty�s���}�}�R� � ��,�,r/c�x�d�t|j���dd����S)NzRe:({})z\\�\)r�r�r7r�r�s r-rzRegex._generateDefaultName�s0������T�\� 2� 2� :� :�6�4� H� H�I�I�Ir/Tc�<�|�||��}|st|||j|���|���}t	|�����}|���}|r|���D]
\}}|||<�||fSr))rr�rr�r r.�	groupdict�items)	r+r�r�rrur5�d�k�vs	         r-rHzRegex.parseImpl�s������x��-�-���	C� ��3���T�B�B�B��j�j�l�l���6�<�<�>�>�*�*���������	����	�	�
�
���1���A����C�x�r/c��|�||��}|st|||j|���|���}|���}||fSr))rr�rr��groups�r+r�r�rrur5s      r-r=zRegex.parseImplAsGroupList�sW�����x��-�-���	C� ��3���T�B�B�B��j�j�l�l���m�m�o�o���C�x�r/c��|�||��}|st|||j|���|���}|}||fSr))rr�rr�rMs      r-r>zRegex.parseImplAsMatch�sO�����x��-�-���	C� ��3���T�B�B�B��j�j�l�l�����C�x�r/�replrXc������jrtd����jrt���rtd����jr�fd�}n��fd�}��|��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(asGroupList=True)z9cannot use sub() with a callable with Regex(asMatch=True)c�:��|d����Sr)�expand)r[rOs �r-r�zRegex.sub.<locals>.pa�s����a�y�'�'��-�-�-r/c�F���j��|d��Sr)r�sub)r[rOr+s ��r-r�zRegex.sub.<locals>.pa�s����w�{�{�4����3�3�3r/)r5r�r6r(r5)r+rOr�s`` r-rTz	Regex.sub�s�������	M��K�L�L�L��<�	Y�H�T�N�N�	Y��W�X�X�X��<�	4�
.�
.�
.�
.�
.�
.�

4�
4�
4�
4�
4�
4��$�$�R�(�(�(r/)rFFr�)r2r7r8rGrrr�	RegexFlagr�rr.r&rr�rrHr=r>r�r�rTr�r�s@r-r4r4Jsq���������6+,�#��,3�"��,3�,3�,3��,3��R�\�3�&�'�,3��	,3�
�,3��,3��,3�,3�,3�,3�,3�,3�\�	�	��_�	�����_���-�-��_�-�J�J�J�������������)��)�
�)�)�)�)�)�)�)�)r/r4c���eZdZdZdZ							dddddddd�ded	ejed
ejededed
ejedededejedejededejedef�fd�Z	d�Z
dd�Z�xZS)�QuotedStringa
    Token for matching strings that are delimited by quoting characters.

    Defined with the following parameters:

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

    Example::

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

    prints::

        [['This is the quote']]
        [['This is the "quote"']]
        [['This is the quote with "embedded" quotes']]
    ))z\t�	)rVrW)z\f�)z\r�
r~NFT)�	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�����|	p|}	|
p|}
|o|}|p|}|
o|}
|p|}|���}|std���|�|}n%|���}|std���|�_t|���_|d�_|�_t|���_	|	�_
|
�_|�_|
�_
d}d}|
r-|d�|tj|
����z
}d}|	rN|d�|tj|	����z
}d}tj�j
��dz�_t�j��d	krc|d
�|��d��fd�t't�j��d	z
dd��D����zd
zz
}d}|rbtjtjz�_|d�|t/�jd��|	�t/|	��nd��z
}nJd�_|d�|t/�jd��|	�t/|	��nd��z
}d�tj�j��d|dtj�j��g���_	tj�j�j���_�j�_�jj�_n:#tj$r(td��j�����wxYwd�jz�_d�_ d�_!dS)Nz%quote_char cannot be the empty stringz'endQuoteChar cannot be the empty stringrr~z{}(?:{})�|z	{}(?:{}.)z(.)rz{}(?:c	3��K�|]X}d�tj�jd|���tj�j|d�����V��YdS)z(?:{}(?!{}))N)r�rrr_)rCr|r+s  �r-r*z(QuotedString.__init__.<locals>.<genexpr>Ns{�������
�	#�)�)��	�$�"3�B�Q�B�"7�8�8��	�$�"3�A�B�B�"7�8�8��������r/r��)z
{}(?:[^{}{}])z{}(?:[^{}\n\r{}])z(?:z)*z$invalid pattern {!r} passed to RegexrFT)"r�r.rZr�r[rB�quoteCharLen�firstQuoteCharr_�endQuoteCharLenr\r]r^r`r�rr�escCharReplacePatternr��range�	MULTILINE�DOTALLr8rr7rrr�rr rUrrr�)r+rarbrcrdrerfrgr[r\r]r^r_r`�sep�
inner_patternr�s`               �r-r.zQuotedString.__init__s�����"	���������%�X���(�y��'�;�O��#�5�~��$�C�)C�	!��,�*�
� �%�%�'�'�
��	F��D�E�E�E���%�L�L�'�-�-�/�/�L��
L� �!J�K�K�K�#����
�O�O���(��m���(���"�<�0�0������ ��
�,���(@��%����
��	��[�/�/��R�Y�x�5H�5H�I�I�I�M��C��	I��\�0�0��b�i��6H�6H�I�I�I�M��C�)+��4�<�)@�)@�5�)H�D�&��t� �!�!�A�%�%�����s�#�#��(�(�����
#�3�t�'8�#9�#9�A�#=�q�"�E�E���������

�M��C��
	����	�1�D�J��-�4�4��)�$�*;�A�*>�?�?�7>�7J�*�7�3�3�3�PR���
�M�M��D�J��1�8�8��)�$�*;�A�*>�?�?�7>�7J�*�7�3�3�3�PR���
�M��w�w��	�$�.�)�)�����	�$�+�,�,�
�
�
���	��j���t�z�:�:�D�G� �L�D�M� �G�M�D�M�M���x�	�	�	��6�=�=�d�l�K�K���
�	����
"�D�I�-���"���"����s
�#AL%�%7Mc���|j|jkr4t|jt��rd�|j��Sd�|j|j��S)Nzstring enclosed in {!r}z.quoted string, starting with {} ending with {})r[r_rSr#r�r�s r-rz!QuotedString._generateDefaultNames[���>�T�.�.�.�:�d�n�h�3W�3W�.�,�3�3�D�N�C�C�C�?�F�F��N�D�-�
�
�	
r/c�.�|||jkr|�||��pd}|st|||j|���|���}|���}|jr�||j|j�}t|t��rwd|vr*|jr#|jD]\}}|�
||��}�|jrtj|jd|��}|jr |�
|j|j��}||fS)NrDz\g<1>)rmrr�rr�r.r^rlrnrSr#r`�ws_mapr�r\rrTror]r_)r+r�r�rrur5�wslit�wschars        r-rHzQuotedString.parseImpl�s3���S�M�T�0�0�
-��
�
�h��,�,�
��	�
�	C� ��3���T�B�B�B��j�j�l�l���l�l�n�n����	H��d�'�4�+?�*?�?�@�C��#�x�(�(�
H��3�;�;�4�#@�;�)-��9�9�
��v�!�k�k�%��8�8����<�L��&��!;�X�s�K�K�C��=�H��+�+�d�m�T�5F�G�G�C��C�x�r/)r~NNFTNTr�)
r2r7r8rGrwr�r�r�rr.rrHr�r�s@r-rWrW�sn�������%�%�LJ�F��)-�*.�� $�/3�+/�o#��(,�)-�#�-1�)-�o#�o#�o#��o#��/�#�&�o#��?�3�'�	o#�
�o#��
o#����,�o#�%)�o#��o#����%�o#��/�#�&�o#��o#��o�c�*�o#�#'�o#�o#�o#�o#�o#�o#�b
�
�
��������r/rWc�V��eZdZdZ				ddd�dededed	ed
ef
�fd�Zd�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(delimited_list(csv_value).parse_string("dkls,lsdkjf,s12 34,@!#,213"))

    prints::

        ['dkls', 'lsdkjf', 's12 34', '@!#', '213']
    r~rr)�notChars�	not_charsr�r
rr|c�z��t�����d|_|p||_t	|j��|_|dkrt
d���||_|dkr||_nt|_|dkr||_||_d|j
z|_|jdk|_d|_
dS)NFrzacannot specify a minimum length < 1; use Opt(CharsNotIn()) if zero-length char group is permittedrr)r�r.r�r|r��notCharsSetr�rrr�rUrr�r)r+r}r�r
rr|r�s      �r-r.zCharsNotIn.__init__�s����	��������#���!�-�X��
��t�}�-�-�����7�7��K���
�
�����7�7��D�K�K�"�D�K��1�9�9��D�K��D�K�!�D�I�-���"�k�Q�.���"����r/c���t|j��}t|��dkr"d�|jdd���Sd�|j��S)Nr$z
!W:({}...)�
z!W:({}))rr|rBr�)r+�
not_chars_strs  r-rzCharsNotIn._generateDefaultName�sY��2�4�=�A�A�
��}����"�"��&�&�t�}�X�v�X�'>�?�?�?��#�#�D�M�2�2�2r/Tc�V�|j}|||vrt|||j|���|}|dz
}t||jzt|����}||kr|||vr|dz
}||kr
|||v�||z
|jkrt|||j|���||||�fSrA)rr�rr�rrBr)r+r�r�r�notcharsr��maxlens       r-rHzCharsNotIn.parseImpl�s����#���C�=�H�$�$� ��3���T�B�B�B����q����U�T�[�(�#�h�-�-�8�8���F�l�l�x��}�H�<�<��1�H�C��F�l�l�x��}�H�<�<���;���$�$� ��3���T�B�B�B��H�U�3�Y�'�'�'r/)r~rrrr�rr�s@r-r{r{�s����������,����!#��!#�!#�!#��!#��!#��	!#�
�!#��!#�!#�!#�!#�!#�!#�F3�3�3�(�(�(�(�(�(�(�(r/r{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*��Zd6d.ed/ed0ed1ef�fd2�
Zd3�Zd7d5�Z	�xZ
S)8�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>rXz<TAB>rWz<LF>rZz<CR>rYz<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 � 	
rr�wsr�r
rc�h���t�����|�_��d��fd��jD����d���d�_d�jz�_|�_	|dkr|�_
nt�_
|dkr|�_
|�_	dSdS)Nr~c3�.�K�|]}|�jv�|V��dSr))�
matchWhite)rCr�r+s  �r-r*z!White.__init__.<locals>.<genexpr>!
s/�����J�J�!��$�/�1I�1I�A�1I�1I�1I�1I�J�Jr/T�rrr)r�r.r�r	r��	whiteStrsr�rUrrrr�)r+r�r�r
rr�s`    �r-r.zWhite.__init__
s�����
������������!�!��G�G�J�J�J�J�t�~�J�J�J�J�J��	"�	
�	
�	
�
#���!�D�I�-��������7�7��D�K�K�"�D�K��1�9�9��D�K��D�K�K�K��9r/c�J�d�d�|jD����S)Nr~c3�:K�|]}tj|V��dSr))r�r�r�s  r-r*z-White._generateDefaultName.<locals>.<genexpr>4
s)����C�C�a�u��q�)�C�C�C�C�C�Cr/)r�r�r�s r-rzWhite._generateDefaultName3
s%���w�w�C�C�4�?�C�C�C�C�C�Cr/Tc�j�|||jvrt|||j|���|}|dz
}||jz}t	|t|����}||kr)|||jvr|dz
}||kr|||jv�||z
|jkrt|||j|���||||�fSrA)r�r�rrr�rBr)r+r�r�rr�r�s      r-rHzWhite.parseImpl6
s����C�=���/�/� ��3���T�B�B�B����q������$���V�S��]�]�+�+���F�l�l�x��}���?�?��1�H�C��F�l�l�x��}���?�?���;���$�$� ��3���T�B�B�B��H�U�3�Y�'�'�'r/)r�rrrr�)r2r7r8rGr�r�r�r.rrHr�r�s@r-r�r��s������������V���g��	
�f��	
�f�	�
	
�f��	�(�
�	�&��	�/��	�+��	�+��	�,��	�,��	�(��	�'��	�&�� 	�"�!�"	�'�#�$!� �&���'�/���I�4 � �3� �� �s� �s� � � � � � �,D�D�D�
(�
(�
(�
(�
(�
(�
(�
(r/r�c���eZdZ�fd�Z�xZS)�
PositionTokenc�d��t�����d|_d|_dSr;r�r�s �r-r.zPositionToken.__init__G
r�r/)r2r7r8r.r�r�s@r-r�r�F
s8�������#�#�#�#�#�#�#�#�#r/r�c�6��eZdZdZdef�fd�Zd�Zdd�Z�xZS)�
GoToColumnzaToken to advance to a specific column of input text; useful for
    tabular report scraping.
    �colnoc�V��t�����||_dSr))r�r.r�)r+r�r�s  �r-r.zGoToColumn.__init__R
s$���
������������r/c�~�t||��|jkr�t|��}|jr|�||��}||krq||���rWt||��|jkr>|dz
}||kr3||���rt||��|jk�>|SrA)r�rBr�r?�isspace)r+r�r�rCs    r-rEzGoToColumn.preParseV
s����s�H�����)�)��8�}�}�H���
:��*�*�8�S�9�9���h����S�M�)�)�+�+����X�&�&�$�(�2�2��q���	�h����S�M�)�)�+�+����X�&�&�$�(�2�2��
r/Tc��t||��}||jkrt||d|���||jz|z
}|||�}||fS)NzText not in expected column)r�r�)r+r�r�r�thiscol�newlocr5s       r-rHzGoToColumn.parseImplc
s[���c�8�$�$���T�X��� ��3�0M�t�T�T�T��t�x��'�)���s�6�z�"���s�{�r/r�)	r2r7r8rGr�r.rErHr�r�s@r-r�r�M
sq����������c�����������������r/r�c�0��eZdZdZ�fd�Zd�Zdd�Z�xZS)�	LineStarta�Matches if current position is at the beginning of a line within
    the parse string

    Example::

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

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

    prints::

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

    c�>��t�����|���t��|jz|_|j�d��t���|j��|_	d|_
dS)NrWzExpected start of line)r�r.rr�r��orig_whiteChars�discardr�r	r�rr�s �r-r.zLineStart.__init__�
sz���
��������������"�u�u�t��6��������%�%�%��w�w�3�3�D�O�D�D���.����r/c���|dkr|S|j�||��}d|jvr@|||dz�dkr/|j�||dz��}|||dz�dk�/|S)NrrWr)r�rEr�)r+r�r�r5s    r-rEzLineStart.preParse�
s����!�8�8��J��,�'�'��#�6�6�C��t�+�+�+��s�S�1�W�}�-��5�5��,�/�/��#��'�B�B�C��s�S�1�W�}�-��5�5��Jr/Tc�`�t||��dkr|gfSt|||j|���rA)r�r�rrGs    r-rHzLineStart.parseImpl�
s6���s�H����"�"���7�N��X�s�D�K��>�>�>r/r�)r2r7r8rGr.rErHr�r�s@r-r�r�l
se���������,/�/�/�/�/����?�?�?�?�?�?�?�?r/r�c�*��eZdZdZ�fd�Zdd�Z�xZS)�LineEndzTMatches if current position is at the end of a line within the
    parse string
    c����t�����|j�d��|�|jd���d|_dS)NrWFr�zExpected end of line)r�r.r�r�r	rr�s �r-r.zLineEnd.__init__�
sU���
�������������%�%�%��!�!�$�/��!�G�G�G�,����r/Tc���|t|��kr*||dkr|dzdfSt|||j|���|t|��kr|dzgfSt|||j|���)NrWr�rBr�rrGs    r-rHzLineEnd.parseImpl�
s{����X�������}��$�$��Q�w��}�$�$�X�s�D�K��F�F�F�
�C��M�M�
!�
!���7�B�;�� ��3���T�B�B�Br/r�r�r�s@r-r�r��
s^���������-�-�-�-�-�	C�	C�	C�	C�	C�	C�	C�	Cr/r�c�*��eZdZdZ�fd�Zdd�Z�xZS)�StringStartzLMatches if current position is at the beginning of the parse
    string
    c�V��t�����d|_dS)NzExpected start of text�r�r.rr�s �r-r.zStringStart.__init__�
s$���
��������.����r/Tc�x�|dkr1||�|d��krt|||j|���|gfSr)rEr�rrGs    r-rHzStringStart.parseImpl�
sC���!�8�8��d�m�m�H�a�0�0�0�0�$�X�s�D�K��F�F�F��B�w�r/r�r�r�s@r-r�r��
sV���������/�/�/�/�/��������r/r�c�*��eZdZdZ�fd�Zdd�Z�xZS)r�zG
    Matches if current position is at the end of the parse string
    c�V��t�����d|_dS)NzExpected end of textr�r�s �r-r.zStringEnd.__init__�
s$���
��������,����r/Tc���|t|��krt|||j|���|t|��kr|dzgfS|t|��kr|gfSt|||j|���rAr�rGs    r-rHzStringEnd.parseImpl�
sx����X����� ��3���T�B�B�B�
�C��M�M�
!�
!���7�B�;��
�3�x�=�=�
 �
 ���7�N� ��3���T�B�B�Br/r�r�r�s@r-r�r��
s^���������-�-�-�-�-�C�C�C�C�C�C�C�Cr/r�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���|tkr|n|}t�����t|��|_d|_dS)NzNot at the start of a word)�
printablesr�r.r�r�r�r+r�r�r�s   �r-r.zWordStart.__init__�
sD���"+�z�"9�"9�J�J�y�	�
���������Y�����2����r/Tc��|dkr8||dz
|jvs|||jvrt|||j|���|gfS�Nrr)r�r�rrGs    r-rHzWordStart.parseImpl�
sQ���!�8�8���q��!�T�^�3�3��C�=���6�6�$�X�s�D�K��F�F�F��B�w�r/r��	r2r7r8rGr�r�r.rHr�r�s@r-r�r��
s���������*4�3��3�3�3�3�3�3�3�3�3�3�3�3��������r/r�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���|tkr|n|}t�����t|��|_d|_d|_dS)NFzNot at the end of a word)r�r�r.r�r�r�rr�s   �r-r.zWordEnd.__init__�
sL���"+�z�"9�"9�J�J�y�	�
���������Y�����#���0����r/Tc��t|��}|dkr>||kr8|||jvs||dz
|jvrt|||j|���|gfSr�)rBr�r�r)r+r�r�rrCs     r-rHzWordEnd.parseImplsd���x�=�=���a�<�<�C�(�N�N���
���/�/��C�!�G�$�D�N�:�:�$�X�s�D�K��F�F�F��B�w�r/r�r�r�s@r-r�r��
s���������*4�1��1�1�1�3�1�3�1�1�1�1�1�1��������r/r�c����eZdZdZddejedef�fd�
Zde	efd�Z
defd�Zdd
edef�fd�
Zdd
edef�fd�
Z
def�fd
�Zd�Zdef�fd�Zddd�Zdef�fd�Zd�fd�	Ze
ZeZ�xZS)�ParseExpressionz]Abstract subclass of ParserElement, for combining and
    post-processing parsed tokens.
    F�exprsr�c�`���t���|���t|t��rt	|��}t|t
��r��|��g�_n�t|t��r	|g�_n�t|t��rKt	|��}td�|D����r�fd�|D��}t	|���_n.	t	|���_n#t$r|g�_YnwxYwd�_dS)Nc3�@K�|]}t|t��V��dSr))rSr#)rCr�s  r-r*z+ParseExpression.__init__.<locals>.<genexpr>s,����@�@�$�:�d�H�-�-�@�@�@�@�@�@r/c3�p�K�|]0}t|t��r��|��n|V��1dSr))rSr#r�)rCr=r+s  �r-r*z+ParseExpression.__init__.<locals>.<genexpr>sZ��������4>�a��3J�3J�Q�D�,�,�Q�/�/�/�PQ������r/F)
r�r.rS�_generatorTyper�r#r�r�r�r�anyr�r�r+r�r�r�s`  �r-r.zParseExpression.__init__sG����
������"�"�"��'��e�^�,�,�	 ���K�K�E��e�X�&�&�	%��2�2�5�9�9�:�D�J�J�
��}�
-�
-�	%���D�J�J�
��x�
(�
(�
	%���K�K�E��@�@�%�@�@�@�@�@�
�����"������e���D�J�J�
%�!�%�[�[��
�
���
%�
%�
%�#�W��
�
�
�
%����!����s�:D�D$�#D$rXc� �|jdd�Sr))r�r�s r-r&zParseExpression.recurse+s���z�!�!�!�}�r/c�H�|j�|��d|_|Sr))r�r	r�r�s  r-r	zParseExpression.append.s%���
���%� � � � ����r/Trc���t���|��|r5d�|jD��|_|jD]}|�|���|S)z�
        Extends ``leave_whitespace`` defined in base class, and also invokes ``leave_whitespace`` on
           all contained expressions.
        c�6�g|]}|�����Sr9�r�rCr=s  r-rEz4ParseExpression.leave_whitespace.<locals>.<listcomp>;� ��7�7�7�q�!�&�&�(�(�7�7�7r/)r�rr��r+rr=r�s   �r-rz ParseExpression.leave_whitespace3si���
	��� � ��+�+�+��	.�7�7�D�J�7�7�7�D�J��Z�
.�
.���"�"�9�-�-�-�-��r/c���t���|��|r5d�|jD��|_|jD]}|�|���|S)z�
        Extends ``ignore_whitespace`` defined in base class, and also invokes ``leave_whitespace`` on
           all contained expressions.
        c�6�g|]}|�����Sr9r�r�s  r-rEz5ParseExpression.ignore_whitespace.<locals>.<listcomp>Gr�r/)r�rr�r�s   �r-rz!ParseExpression.ignore_whitespace@si���
	���!�!�)�,�,�,��	/�7�7�D�J�7�7�7�D�J��Z�
/�
/���#�#�I�.�.�.�.��r/c�r��t|t��rU||jvrKt���|��|jD]"}|�|jd���#nKt���|��|jD]"}|�|jd���#|S�Nr�)rSr�r�r�r
r�)r+r�r=r�s   �r-r
zParseExpression.ignoreLs�����e�X�&�&�	/��D�,�,�,������u�%�%�%���3�3�A��H�H�T�-�b�1�2�2�2�2���G�G�N�N�5�!�!�!��Z�
/�
/������)�"�-�.�.�.�.��r/c�f�d�|jjt|j����S�Nz{}:({}))r�r�r2r�r�r�s r-rz$ParseExpression._generateDefaultNameXs%������� 7��T�Z���I�I�Ir/c�$��|jr|St�����|jD]}|����t	|j��dk�r|jd}t||j��ri|jsb|j�[|j	sT|jdd�|jdgz|_d|_
|xj|jzc_|xj|jzc_|jd}t||j��rj|jsc|j�\|j	sU|jdd�|jdd�z|_d|_
|xj|jzc_|xj|jzc_dt|��z|_|S)Nrkrrr�r)r�r�r�r�rBrSr�r�r�r�r�r�rr�r)r+r=r�r�s   �r-r�zParseExpression.streamline[s������	��K�
����������	�	�A�
�L�L�N�N�N�N�
�t�z�?�?�a����J�q�M�E��5�$�.�1�1�	
:��)�	
:��%�-���.�#�[����^�t�z�!�}�o�=��
�$(��!��#�#�u�';�;�#�#��"�"�e�&9�9�"�"��J�r�N�E��5�$�.�1�1�	
:��)�	
:��%�-���.�"�Z����_�u�{�1�1�1�~�=��
�$(��!��#�#�u�';�;�#�#��"�"�e�&9�9�"�"�!�C��I�I�-����r/Nc��|�|ngdd�|gz}|jD]}|�|���|�g��dSr))r�r/r))r+r.�tmpr=s    r-r/zParseExpression.validate�s\�� -� 9�}�}�r�1�1�1�E���N����	�	�A�
�J�J�s�O�O�O�O����R� � � � � r/c�t��t�����}d�|jD��|_|S)Nc�6�g|]}|�����Sr9r�r�s  r-rEz(ParseExpression.copy.<locals>.<listcomp>�s ��2�2�2�!�Q�V�V�X�X�2�2�2r/)r�rr��r+r5r�s  �r-rzParseExpression.copy�s0����g�g�l�l�n�n��2�2�t�z�2�2�2��	��
r/c
�~��tjr�tj|jvr||jD]t}t|t��r]|jrVtj|jvrCtj	d�
d|t|��j|j��d����ut���||��S�NzY{}: setting results name {!r} on {} expression collides with {!r} on contained expressionr`r$��
stacklevel)rOr`rjrr�rSr�r��warningsrSr�r�r2r�r�r+rUrr=r�s    �r-rzParseExpression._setResultsName�s�����>�	��E��*�+�+��Z�
�
���q�-�0�0���
��$�M��/�0�0��M�E�EK�V�G� � ��J�J�/��M�	F�F�$%�	�	�	�	���w�w�&�&�t�^�<�<�<r/r~r�r)r^)r2r7r8rGr�rr�rr.rr&r	rrr
rr�r/rrr�r�r�r�s@r-r�r�s����������"�"�f�o�m�<�"��"�"�"�"�"�"�4��-�0������}�����
��$��-�������
�
�4�
�=�
�
�
�
�
�
�
�}�
�
�
�
�
�
�J�J�J�'�M�'�'�'�'�'�'�R!�!�!�!�!��m�������
=�=�=�=�=�=�4)��&�O�O�O�O�Or/r�c���eZdZdZGd�de��Z	ddejede	f�fd�
Z
def�fd	�Zdd
�Zd�Z
d�Zd
�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�Zd�Z�xZS)�And._ErrorStopc�b��t��j|i|��|���dSr))r�r.r)r+r�r1r�s   �r-r.zAnd._ErrorStop.__init__�s7����E�G�G��d�-�f�-�-�-��!�!�#�#�#�#�#r/c��dS)N�-r9r�s r-rz#And._ErrorStop._generateDefaultName�s���3r/)r2r7r8r.rr�r�s@r-r�r��sG�������	$�	$�	$�	$�	$�	�	�	�	�	�	�	r/r�T�	exprs_argr�c�B��t|��}|r�t|vr�g}t|��D]�\}}|turv|t|��dz
krQt	��||dzzjd}|�t|��d�����utd���|�|����||dd�<t���
||��|jr�td�|jD����|_t|jdt��sO|�|jdj|jdj���|jdj|_nd|_nd	|_d	|_dS)
Nrr�r�z0cannot construct And with sequence ending in ...c3�$K�|]}|jV��dSr)�r�r�s  r-r*zAnd.__init__.<locals>.<genexpr>��%����%K�%K�1�a�&6�%K�%K�%K�%K�%K�%Kr/rr�FT)r�r�r�rBr�r�r	r�rRr�r.r.r�rSr�r	r�r�r�r)	r+r�r�r�r�r|r��
skipto_argr�s	        �r-r.zAnd.__init__�s����&*�)�_�_���
	�X��&�&��C�$�U�+�+�

%�

%���4��8�#�#��3�u�:�:��>�)�)�5:�W�W�u�Q��U�|�5K�4R�SU�4V�
��
�
�#5�6�*�#5�#5�k�#B�#B�C�C�C�C�'�N�����J�J�t�$�$�$�$��E�!�!�!�H�
�������)�)�)��:�	'�"%�%K�%K��
�%K�%K�%K�"K�"K�D���d�j��m�U�3�3�
,��)�)��J�q�M�,�"&�*�Q�-�"E�*����'+�j��m�&B��#�#�&+��#�#�"&�D�� ����r/rXc����|jr�td�|jdd�D����r�t|jdd���D]w\}}|��t|t��rZ|jrSt|jdt
��r3|jd|j|dzz|jd<d|j|dz<�xd�|jD��|_t
�����t|j|jdd���D]�\}}t��}|r�t|��|vrn�|�t|����t|t��r|�
|fd���n3|���}tt!|��d��}|����t#d�|jD����|_|S)Nc3�K�|]@}t|t��o&|jot|jdt��V��AdS�r�N)rSr�r�r�r�s  r-r*z!And.streamline.<locals>.<genexpr>�sd��������1�o�.�.�:��G�:��q�w�r�{�L�9�9������r/r�rc��g|]}|�|��Sr)r9r�s  r-rEz"And.streamline.<locals>.<listcomp>�s��E�E�E�A�q�}�a�}�}�}r/c�@�t|dt||����S)N�
parent_anchor)�setattrr�)r�r�r��cur_s    r-r�z And.streamline.<locals>.<lambda>
s��'� �/�3�q�!�9�9�3�3�r/c3�$K�|]}|jV��dSr)r�r�s  r-r*z!And.streamline.<locals>.<genexpr>s%����!G�!G�q�!�"2�!G�!G�!G�!G�!G�!Gr/)r�r�r�rSr�r�r�r�r�r�rA�add�
IndentedBlockr5r&�nextr�r.r�)r+r|r=�prev�cur�seen�subsr�s       �r-r�zAnd.streamline�s
����:�	F������C�R�C��	�����
F�&�d�j��"��o�6�6�	1�	1�D�A�q��y� �"�1�o�6�6�1��G�1�'�q�w�r�{�L�A�A�1�
'(�g�b�k�D�J�q�1�u�4E�&E�����,0��
�1�q�5�)��E�E���E�E�E��
�
���������T�Z���A�B�B��8�8�	-�	-�I�D�#��5�5�D��
-��c�7�7�d�?�?������C���!�!�!��c�=�1�1���)�)�-0�������
��{�{�}�}���4��:�:�t�,�,���
-��"�!G�!G�D�J�!G�!G�!G�G�G����r/c�6�|jd�|||d���\}}d}|jdd�D]�}t|��tjurd}� |r�	|�|||��\}}n�#t
$r�t$r&}d|_t
�|���d}~wt$r%t|t|��|j|���wxYw|�|||��\}}|s|���r||z
}��||fS)NrFr�rT)
r�r"r�r�r��ParseSyntaxExceptionrmr��_from_exceptionrQrBr�haskeys)	r+r�r�r�
resultlist�	errorStopr=�
exprtokensrss	         r-rHz
And.parseImplsh���*�Q�-�.�.��c�9�5�/�
�
���Z��	���A�B�B��	)�	)�A��A�w�w�#�.�(�(� �	���

E�
�&'�h�h�x��i�&H�&H�O�C����+�����)�C�C�C�'+�B�$�.�>�>�r�B�B�B�����!����.� �#�h�-�-���d��������
#$�(�(�8�S�)�"D�"D���Z��
)�Z�/�/�1�1�
)��j�(�
���J��s�A7�7C�!B,�,2Cc��t|t��r|�|��}|�|��Sr)�rSr#r�r	r�s  r-�__iadd__zAnd.__iadd__3�9���e�X�&�&�	4��,�,�U�3�3�E��{�{�5�!�!�!r/c�t�|dd�|gz}|jD]!}|�|��|jsdS�"dSr))r�r)r�r*s    r-r)zAnd._checkRecursion8s]��*�1�1�1�-���6����	�	�A�
���o�.�.�.��#�
����
�	�	r/c�6�d�d�|jD����}t|��dkr[|ddt|��dz
�dkr<|dd�}t|��dkr|ddt|��dz
�dk�<d|zdzS)	Nr�c3�4K�|]}t|��V��dSr)r�r�s  r-r*z+And._generateDefaultName.<locals>.<genexpr>@s(����4�4�A��Q���4�4�4�4�4�4r/rr�{}r��{�})r�r�rB�r+�inners  r-rzAnd._generateDefaultName?s������4�4���4�4�4�4�4���%�j�j�1�n�n��q�':�C��J�J��N�':�!;�t�!C�!C��!�B�$�K�E��%�j�j�1�n�n��q�':�C��J�J��N�':�!;�t�!C�!C��U�{�S� � r/r�)r2r7r8rGr�r�r�rr�rr.r�rHr
r)rr�r�s@r-r�r��s����������"�����U����KO�!�!����7�!�CG�!�!�!�!�!�!�B+�M�+�+�+�+�+�+�Z����<"�"�"�
���!�!�!�!�!�!�!r/r�c�t��eZdZdZd
dejedef�fd�
Zdef�fd�Z	dd	�Z
d
�Zd�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']]
    Fr�r�c���t���||��|jrHtd�|jD����|_td�|jD����|_dSd|_dS)Nc3�$K�|]}|jV��dSr)r�r�s  r-r*zOr.__init__.<locals>.<genexpr>\r�r/c3�$K�|]}|jV��dSr)rr�s  r-r*zOr.__init__.<locals>.<genexpr>]r�r/T�r�r.r�r�r�r.r�r�s   �r-r.zOr.__init__Y�}���
�������)�)�)��:�	'�"%�%K�%K��
�%K�%K�%K�"K�"K�D��"%�%K�%K��
�%K�%K�%K�"K�"K�D����"&�D���r/rXc�8��t�����|jrjtd�|jD����|_td�|jD����|_t
d�|jD����|_nd|_|S)Nc3�$K�|]}|jV��dSr)r�r�s  r-r*z Or.streamline.<locals>.<genexpr>dr�r/c3�$K�|]}|jV��dSr)�r�r�s  r-r*z Or.streamline.<locals>.<genexpr>e�$����!C�!C�1�!�,�!C�!C�!C�!C�!C�!Cr/c3�PK�|]!}|jot|t��V��"dSr)�r�rSr�r�s  r-r*z Or.streamline.<locals>.<genexpr>f�H����&�&�BC�� �=��A�u�)=�)=�%=�&�&�&�&�&�&r/F)r�r�r�r�r�r�r.r�r�s �r-r�z
Or.streamlineas����
���������:�	$�"%�%K�%K��
�%K�%K�%K�"K�"K�D��!�!C�!C��
�!C�!C�!C�C�C�D�O�"%�&�&�GK�z�&�&�&�#�#�D���$�D�O��r/Tc�0�d}d}g}g}td�|jD����r|�||��}|jD]�}	|�||d���}	|�|	|f���3#t
$r1}
d|
_||
_|�|
��d}d}Yd}
~
�id}
~
wt$r'}|sd|_|j	|kr	|}|j	}Yd}~��d}~wt$rIt|��|kr3t|t|��|j|��}t|��}Y��wxYw|r�|�
td��d���|s%|dd}|�|||��Sd}
|D]~\}}||
dkr|
cS	|�|||��\}	}|	|kr|	|fcS|	|
dkr|	|f}
�M#t$r%}d|_|j	|kr	|}|j	}Yd}~�wd}~wwxYw|
dkr|
S|rgt|��dkrJ|�
d	��
��|dj	|dj	kr|�
d��
��|d}|�|�|j|_|�t||d|���)
Nr�c3�$K�|]}|jV��dSr))rr�s  r-r*zOr.parseImpl.<locals>.<genexpr>rs$����2�2�!�q�~�2�2�2�2�2�2r/T�r`r)r��reverserr�c��|jSr)�r��r=s r-r�zOr.parseImpl.<locals>.<lambda>��
��1�5�&�r/�r�c�V�|jtt|j����fSr)�r�rBr��
parserElementr(s r-r�zOr.parseImpl.<locals>.<lambda>��$����v��C���<P�<P�8Q�8Q�7Q�.R�r/� no defined alternatives to match)r.r�rErcr	r�r�r-r�r�rQrBr�sortrr"r�)r+r�r�r�	maxExcLoc�maxExceptionr��fatalsr=�loc2�pfer\�	best_expr�longest�loc1�expr1r��	max_fatals                  r-rHzOr.parseImplmsP���	��������2�2�t�z�2�2�2�2�2�	/��-�-��#�.�.�C���	*�	*�A�
*��{�{�8�S�d�{�C�C��*����a�y�)�)�)�)��)'�
�
�
�$(��!�$%��!��
�
�c�"�"�"�#���	�	�	�	�	�	�����!�
,�
,�
,��,�(,�C�%��w��*�*�'*��$'�G�	�����������
.�
.�
.��x�=�=�9�,�,�#1� �#�h�-�-���4�$�$�L�!$�H�
�
�I���
.����� 	�
�L�L�Z��]�]�D�L�9�9�9��
B�$�A�J�q�M�	� �'�'��#�y�A�A�A��G�&�
-�
-���e��7�1�:�%�%�"�N�N�N�-�!&���h��Y�!G�!G�J�D�$��t�|�|�#�T�z�)�)�)����
�*�*�"&��*����&�,�,�,�(,�C�%��w��*�*�'*��$'�G�	����������	,�����*�$�$����	��6�{�{�Q������ 0� 0��1�1�1��!�9�=�F�1�I�M�1�1��K�K�$R�$R�K�S�S�S��q�	�I��O��#�#�{�L���� ��#�A�4���
sC�A7�7
D2�'B-�-
D2�:C�AD2�1D2�G�
H�G=�=Hc��t|t��r|�|��}|�|��Sr)r	r�s  r-�__ixor__zOr.__ixor__�rr/c�V�dd�d�|jD����zdzS)Nrz ^ c3�4K�|]}t|��V��dSr)r�r�s  r-r*z*Or._generateDefaultName.<locals>.<genexpr>��(����;�;�1��A���;�;�;�;�;�;r/r�r�r�r�s r-rzOr._generateDefaultName��/���U�Z�Z�;�;��
�;�;�;�;�;�;�c�A�Ar/c	�<��tjrntj|jvr[t	d�|jD����r=t
jd�d|t|��j
��d���t���||��S)Nc3�fK�|],}t|t��otj|jvV��-dSr)�rSr�rjr_rr�s  r-r*z%Or._setResultsName.<locals>.<genexpr>��X��������1�c�"�"�,��I��+�,������r/��{}: 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 Groupr_r$r��
rOr_rjrr�r�r�rSr�r�r2r�r�r+rUrr�s   �r-rzOr._setResultsName������>�	��E��*�+�+������	�����
��
�2�39�&�C���T�
�
�+�3�3�
 !�
�
�
�
��w�w�&�&�t�^�<�<�<r/r~r�)r2r7r8rGr�rr�rr.r�rHr<rrr�r�s@r-r�r�Gs����������"'�'�f�o�m�<�'��'�'�'�'�'�'�
�M�
�
�
�
�
�
�P�P�P�P�d"�"�"�
B�B�B�=�=�=�=�=�=�=�=�=�=r/r�c�t��eZdZdZd
dejedef�fd�
Zdef�fd�Z	dd	�Z
d
�Zd�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']]
    Fr�r�c���t���||��|jrHtd�|jD����|_td�|jD����|_dSd|_dS)Nc3�$K�|]}|jV��dSr)r�r�s  r-r*z&MatchFirst.__init__.<locals>.<genexpr>�r�r/c3�$K�|]}|jV��dSr)rr�s  r-r*z&MatchFirst.__init__.<locals>.<genexpr>�r�r/Trr�s   �r-r.zMatchFirst.__init__�rr/rXc�X��|jr|St�����|jrjt	d�|jD����|_t	d�|jD����|_td�|jD����|_nd|_d|_|S)Nc3�$K�|]}|jV��dSr)rr�s  r-r*z(MatchFirst.streamline.<locals>.<genexpr>rr/c3�$K�|]}|jV��dSr)r�r�s  r-r*z(MatchFirst.streamline.<locals>.<genexpr>r�r/c3�PK�|]!}|jot|t��V��"dSr)r r�s  r-r*z(MatchFirst.streamline.<locals>.<genexpr>r!r/FT)	r�r�r�r�r�r�r�r.r�r�s �r-r�zMatchFirst.streamline�s������	��K�
���������:�	'�!�!C�!C��
�!C�!C�!C�C�C�D�O�"%�%K�%K��
�%K�%K�%K�"K�"K�D��"%�&�&�GK�z�&�&�&�#�#�D���$�D�O�"&�D���r/Tc���d}d}|jD]�}	|�|||��cS#t$r}d|_||_�d}~wt
$r}|j|kr	|}|j}Yd}~�[d}~wt$rIt|��|kr3t|t|��|j	|��}t|��}Y��wxYw|�|j	|_
|�t||d|���)Nr�r/)r�r"r�r�r-r�r�rQrBrr�)	r+r�r�rr1r2r=r5r\s	         r-rHzMatchFirst.parseImpls9���	�����	.�	.�A�
.��x�x����������
'�
�
�
�$(��!�$%��!������!�
(�
(�
(��7�Y�&�&�#&�L� #��I�����������
.�
.�
.��x�=�=�9�,�,�#1� �#�h�-�-���4�$�$�L�!$�H�
�
�I���
.�����#�#�{�L���� ��#�A�4���
s'�(�
B=�A�
B=�A'�'AB=�<B=c��t|t��r|�|��}|�|��Sr)r	r�s  r-�__ior__zMatchFirst.__ior__.rr/c�V�dd�d�|jD����zdzS)Nrz | c3�4K�|]}t|��V��dSr)r�r�s  r-r*z2MatchFirst._generateDefaultName.<locals>.<genexpr>4r?r/rr@r�s r-rzMatchFirst._generateDefaultName3rAr/c	�<��tjrntj|jvr[t	d�|jD����r=t
jd�d|t|��j
��d���t���||��S)Nc3�fK�|],}t|t��otj|jvV��-dSr)rDr�s  r-r*z-MatchFirst._setResultsName.<locals>.<genexpr><rEr/rFr_r$r�rGrHs   �r-rzMatchFirst._setResultsName6rIr/r~r�)r2r7r8rGr�rr�rr.r�rHrTrrr�r�s@r-r�r��s����������"'�'�f�o�m�<�'��'�'�'�'�'�'��M�������  � � � �D"�"�"�
B�B�B�=�=�=�=�=�=�=�=�=�=r/r�c�b��eZdZdZd
dejedef�fd�
Zdef�fd�Z	d
d�Z
d	�Z�xZS)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
    Tr�r�c����t���||��|jr$td�|jD����|_nd|_d|_d|_d|_dS)Nc3�$K�|]}|jV��dSr)r�r�s  r-r*z Each.__init__.<locals>.<genexpr>�r�r/T)r�r.r�r.r�r��initExprGroupsr�r�s   �r-r.z
Each.__init__�sn���
�������)�)�)��:�	'�"%�%K�%K��
�%K�%K�%K�"K�"K�D���"&�D��"���"�������r/rXc���t�����|jr$td�|jD����|_nd|_|S)Nc3�$K�|]}|jV��dSr)r�r�s  r-r*z"Each.streamline.<locals>.<genexpr>�r�r/T)r�r�r�r.r�r�s �r-r�zEach.streamline�sT���
���������:�	'�"%�%K�%K��
�%K�%K�%K�"K�"K�D���"&�D���r/c�v��|jr�td�|jD����|_d�|jD��}d�|jD��}||z|_d�|jD��|_d�|jD��|_d�|jD��|_|xj|jz
c_d|_|}|jdd�}|jdd��|jdd�}g}	d}
g}g}|
�rP|�z|z}
|���|���|
D]�}	|�	||d�	��}|	�
|j�t|��|����||vr|�
|���p|�vr��
|����#t$rB}d|_||_|�
|��|�
|��Yd}~��d}~wt"$r|�
|��Y��wxYwt%|��t%|
��krd}
|
��P|rgt%|��d
krJ|�d����|d
j|d
jkr|�d����|d
}|�|rCd�d�|D����}t#||d�|�����|	�fd�|jD��z
}	t/g��}|	D]!}|�|||��\}}||z
}�"||fS)Nc3�lK�|]/}t|t���t|j��|fV��0dSr))rSr�rAr�r�s  r-r*z!Each.parseImpl.<locals>.<genexpr>�sQ���� � �$%�z�!�S�7I�7I� ��A�F���Q�� � � � � � r/c�F�g|]}t|t���|j��Sr9�rSr�r�r�s  r-rEz"Each.parseImpl.<locals>.<listcomp>�s)��E�E�E�q�*�Q��2D�2D�E�A�F�E�E�Er/c�d�g|]-}|j�	t|tttf���+|��.Sr9)r�rSr�r4r�r�s  r-rEz"Each.parseImpl.<locals>.<listcomp>�sL�������#��-7�q�3��z�:R�,S�,S�����r/c�z�g|]8}t|t���|j�|jd�����9S�T)r)rS�_MultipleMatchr�rr�r�s  r-rEz"Each.parseImpl.<locals>.<listcomp>�sO��#�#�#���a��0�0�#���'�'��
��'�M�M�#�#�#r/c�z�g|]8}t|t���|j�|jd�����9Sre)rSr�r�rr�r�s  r-rEz"Each.parseImpl.<locals>.<listcomp>�sO��"�"�"���a��+�+�"���'�'��
��'�M�M�"�"�"r/c�V�g|]&}t|tttf���$|��'Sr9)rSr�r�r�r�s  r-rEz"Each.parseImpl.<locals>.<listcomp>�s>������Z��C��Y�;W�-X�-X�����r/FTr$rc��|jSr)r'r(s r-r�z Each.parseImpl.<locals>.<lambda>�r)r/r*rc�V�|jtt|j����fSr)r,r(s r-r�z Each.parseImpl.<locals>.<lambda>�r.r/z, c�,�g|]}t|����Sr9r�r�s  r-rEz"Each.parseImpl.<locals>.<listcomp>�s�� 9� 9� 9�A��Q��� 9� 9� 9r/z*Missing one or more required elements ({})c�P��g|]"}t|t���|j�v� |��#Sr9rb)rCr=�tmpOpts  �r-rEz"Each.parseImpl.<locals>.<listcomp>�s5���X�X�X�Q�
�1�c�0B�0B�X�q�v�QW�GW�GW�q�GW�GW�GWr/)r\�dictr��opt1map�	optionals�multioptionals�
multirequired�requiredrxrcr	r/rA�remover�r�r-r�rBr0r�r�r�r r")r+r�r�r�opt1�opt2�tmpLoc�tmpReqd�multis�
matchOrder�keepMatching�failedr3�tmpExprsr=r5r:�missing�
total_resultsrrms                    @r-rHzEach.parseImpl�s������	(�� � �)-�� � � ���D�L�F�E�D�J�E�E�E�D��������D�
"�D�[�D�N�#�#���#�#�#�D��
"�"���"�"�"�D��
���:����D�M�
�M�M�T�/�/�M�M�"'�D�����-����"�������"���$�Q�Q�Q�'���
��������	%���'�&�0�H��L�L�N�N�N��L�L�N�N�N��
)�
)��)��[�[��6�t�[�L�L�F��%�%�d�l�&6�&6�r�!�u�u�a�&@�&@�A�A�A��G�|�|����q�)�)�)�)��f����
�
�a�(�(�(���+�%�%�%�(,�C�%�()�C�%��M�M�#�&�&�&��M�M�!�$�$�$�$�$�$�$�$�����%�%�%�%��M�M�!�$�$�$�$�$�%�����6�{�{�c�(�m�m�+�+�$��+�	%�0�	��6�{�{�Q������ 0� 0��1�1�1��!�9�=�F�1�I�M�1�1��K�K�$R�$R�K�S�S�S��q�	�I��O��	��i�i� 9� 9�� 9� 9� 9�:�:�G� ���<�C�C�G�L�L���
�	�X�X�X�X�$�*�X�X�X�X�
�$�R�(�(�
��	%�	%�A��8�8�H�c�9�=�=�L�C���W�$�M�M��M�!�!s�%F,�,
H�68G3�3"H�Hc�V�dd�d�|jD����zdzS)Nrz & c3�4K�|]}t|��V��dSr)r�r�s  r-r*z,Each._generateDefaultName.<locals>.<genexpr>�r?r/rr@r�s r-rzEach._generateDefaultName�rAr/r�)
r2r7r8rGr�rr�rr.r�rHrr�r�s@r-r�r�Qs��������7�7�r��f�o�m�<����������M�������U"�U"�U"�U"�nB�B�B�B�B�B�Br/r�c����eZdZdZddeeefdef�fd�
Zde	efd�Z
dd	�Zdd
edef�fd�
Zdd
edef�fd�
Z
def�fd
�Zdef�fd�Zd�Zddd�Zd�Ze
ZeZ�xZS)�ParseElementEnhancezfAbstract subclass of :class:`ParserElement`, for combining and
    post-processing parsed tokens.
    Fr�r�c���t���|��t|t��r�t	|jt��r|�|��}nTt	t|��|j��rt|��}n"|�t|����}||_	|�~|j
|_
|j|_|�|j
|j���|j|_|j|_|j|_|j�|j��dSdS)Nr�)r�r.rSr#�
issubclassr�r�r�r]r�rr�r	r�r�r�r�rr�r��r+r�r�r�s   �r-r.zParseElementEnhance.__init__�s+���
������"�"�"��d�H�%�%�	?��$�2�E�:�:�
?��/�/��5�5����D��J�J��(@�A�A�
?��t�}�}����/�/���
�
�>�>����	���!%�!3�D��"&�"5�D���%�%���t�/I�
&�
�
�
�#'�"5�D��"�o�D�O� $� 1�D����#�#�D�$4�5�5�5�5�5��r/rXc�$�|j�|jgngSr)�r�r�s r-r&zParseElementEnhance.recurses��"�i�3��	�{�{��;r/Tc�p�|j�|j�|||d���St||d|���)NFr�zNo expression defined)r�r"r�rGs    r-rHzParseElementEnhance.parseImpls>���9� ��9�#�#�H�c�9�5�#�Q�Q�Q� ��3�0G��N�N�Nr/rc����t���|��|r?|j���|_|j�|j�|��|Sr))r�rr�r�r+rr�s  �r-rz$ParseElementEnhance.leave_whitespacesY���
��� � ��+�+�+��	6��	���(�(�D�I��y�$��	�*�*�9�5�5�5��r/c����t���|��|r?|j���|_|j�|j�|��|Sr))r�rr�rr�s  �r-rz%ParseElementEnhance.ignore_whitespace$sY���
���!�!�)�,�,�,��	7��	���(�(�D�I��y�$��	�+�+�I�6�6�6��r/c�z��t|t��rW||jvrMt���|��|j�%|j�|jd��nMt���|��|j�%|j�|jd��|Sr�)rSr�r�r�r
r��r+r�r�s  �r-r
zParseElementEnhance.ignore-s�����e�X�&�&�	7��D�,�,�,������u�%�%�%��9�(��I�$�$�T�%5�b�%9�:�:�:���G�G�N�N�5�!�!�!��y�$��	� � ��!1�"�!5�6�6�6��r/c���t�����|j�|j���|Sr))r�r�r�r�s �r-r�zParseElementEnhance.streamline9s:���
���������9� ��I� � �"�"�"��r/c��||vrt||gz���|dd�|gz}|j�|j�|��dSdSr))�RecursiveGrammarExceptionr�r))r+r+r,s   r-r)z#ParseElementEnhance._checkRecursion?se���#�#�#�+�,<��v�,E�F�F�F�*�1�1�1�-���6���9� ��I�%�%�o�6�6�6�6�6�!� r/Nc��|�g}|dd�|gz}|j�|j�|��|�g��dSr)�r�r/r)�r+r.r�s   r-r/zParseElementEnhance.validateFsZ��� ��M��A�A�A��$��'���9� ��I���s�#�#�#����R� � � � � r/c�f�d�|jjt|j����Sr�)r�r�r2r�r�r�s r-rz(ParseElementEnhance._generateDefaultNameNs%������� 7��T�Y���H�H�Hr/r~r�r)r^)r2r7r8rGrr�r�rr.rr&rHrrr
r�r)r/rr�r�r�r�s@r-r�r��s����������6�6�U�=�#�#5�6�6�$�6�6�6�6�6�6�*<��-�0�<�<�<�<�O�O�O�O���$��-���������4��=�������
�}�
�
�
�
�
�
��M�������7�7�7�!�!�!�!�!�I�I�I�)��&�O�O�O�O�Or/r�c�x��eZdZdZGd�de��ZGd�de��Zddd�d	ed
edef�fd�Z	dd
�Z
�xZS)r�z�
    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����|_|��fd���dS)Nzexpected indent at column {}c�,��t||���kSr)�r��r�r�r�r�s   �r-r�z0IndentedBlock._Indent.__init__.<locals>.<lambda>_s���s�1�a�y�y�G�/C�r/�r�r.r�rr7�r+r�r�s `�r-r.zIndentedBlock._Indent.__init__\sS�����G�G������8�?�?��H�H�D�K����C�C�C�C�D�D�D�D�Dr/�r2r7r8r�r.r�r�s@r-�_Indentr�[sO�������	E�C�	E�	E�	E�	E�	E�	E�	E�	E�	E�	Er/r�c�$��eZdZdef�fd�Z�xZS)�IndentedBlock._IndentGreaterr�c����t�����d����|_|��fd���dS)Nz)expected indent at column greater than {}c�,��t||���kSr)r�r�s   �r-r�z7IndentedBlock._IndentGreater.__init__.<locals>.<lambda>es���s�1�a�y�y�7�/B�r/r�r�s `�r-r.z%IndentedBlock._IndentGreater.__init__bsS�����G�G������E�L�L�W�U�U�D�K����B�B�B�B�C�C�C�C�Cr/r�r�s@r-�_IndentGreaterr�asO�������	D�C�	D�	D�	D�	D�	D�	D�	D�	D�	D�	Dr/r�FT�r�groupedr�rr�c�x��t���|d���||_||_d|_dS)NTr�r)r�r.�
_recursive�_groupedr�)r+r�rr�r�s    �r-r.zIndentedBlock.__init__gs@���	��������-�-�-�$�����
�����r/c�r�t���||��}|j�|||��t	||��}|�|��}t��|z|jz}|jrl|�|��}t|j|j|j	���}	|	�
|j��||	_|t||	z��z
}|�dtt!|����dd�����d|����t%|��}
|�|j��t'��z}|j	rt(}nd�}||
��t+|��z�|||��S)Nr�zinner ����@c��|Sr)r9r�s r-r�z)IndentedBlock.parseImpl.<locals>.<lambda>�s��4�r/)r�rEr�rcr�r�r�r�r�r�rr�r�r�r�hexrAr�r�r��Groupr�rH)
r+r�r�r�
anchor_loc�
indent_col�peer_detect_expr�
inner_expr�
sub_indent�nested_block�block�trailing_undentr�s
             r-rHzIndentedBlock.parseImplqs����W�W�%�%�h��4�4�
�	
�	���H�j�)�<�<�<���X�.�.�
��<�<�
�3�3���W�W�/�/�$�)�;�
��?�	9��,�,�Z�8�8�J�(��	�T�_�d�m����L�
�"�"�4�:�.�.�.�)3�L�&��#�j�<�7�8�8�8�J����T�S��J���%8�%8����%=�%C�%C�%E�%E�T�T�
�T�T�U�U�U��*�%�%���,�,�t�'9�:�:�Y�[�[�H���=�	(��G�G�'�'�G�������/�!:�!:�:�E�E��j�)�
�
�	
r/r�)r2r7r8rGr�r�r�r�rr.rHr�r�s@r-r�r�Us����������
E�E�E�E�E�%�E�E�E�D�D�D�D�D��D�D�D�9>�t����!��15��HL�������!
�!
�!
�!
�!
�!
�!
�!
r/r�c�D��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�X��t���|��d|_dS�NF�r�r.r�r+r�r�s  �r-r.zAtStringStart.__init__��)���
���������!����r/Tc�x��|dkrt||d���t���|||��S)Nrznot found at string start)r�r�rH�r+r�r�rr�s    �r-rHzAtStringStart.parseImpl�s;����!�8�8� ��3�0K�L�L�L��w�w� � ��3�	�:�:�:r/r��
r2r7r8rGrr�r�r.rHr�r�s@r-r�r��sv���������"�U�=�#�#5�6�"�"�"�"�"�"�;�;�;�;�;�;�;�;�;�;r/r�c�D��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') + restOfLine).search_string(test):
            print(t)

    prints::

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

    r�c�X��t���|��d|_dSr�r�r�s  �r-r.zAtLineStart.__init__�r�r/Tc���t||��dkrt||d���t���|||��S)Nrznot found at line start)r�r�r�rHr�s    �r-rHzAtLineStart.parseImpl�sG����s�H����"�"� ��3�0I�J�J�J��w�w� � ��3�	�:�:�:r/r�r�r�s@r-r�r��sv���������,"�U�=�#�#5�6�"�"�"�"�"�"�;�;�;�;�;�;�;�;�;�;r/r�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�X��t���|��d|_dSr$�r�r.r�r�s  �r-r.zFollowedBy.__init__�s)���
���������"����r/Tc�T�|j�|||���\}}|dd�=||fS)Nrb)r�r")r+r�r�rr?r5s      r-rHzFollowedBy.parseImpl�s8����!�!�(�C�9�!�E�E���3�����F��C�x�r/r�r�r�s@r-r�r��sl���������,#�U�=�#�#5�6�#�#�#�#�#�#��������r/r�c�^��eZdZdZ	d	deeefdeje	f�fd�
Z
d
d�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

    Nr��retreatc���t���|��|������|_d|_d|_d|_t|t��rt|��}d|_n�t|ttf��r|j}d|_nYt|ttf��r|jt kr|j}d|_nt|t"��r	d}d|_||_dt'|��z|_d|_|j�d���dS)NTFrznot preceded by c�H�|�tdd����Sr))�__delitem__�slice�r�r�r�s   r-r�z%PrecededBy.__init__.<locals>.<lambda>$s���
�
�e�D�$�>O�>O�0P�0P�r/)r�r.r�rr�rrrSr#rBr]r�r�rr{rr�r�r�r�rr�r�r	)r+r�r�r�s   �r-r.zPrecededBy.__init__
s/���	����������I�I�K�K�0�0�2�2��	�"���"�����
��d�H�%�%�	��$�i�i�G��D�J�J�
��w��0�
1�
1�	��m�G��D�J�J�
��t�Z�0�
1�
1�	�d�k�X�6M�6M��k�G��D�J�J�
��m�
,�
,�	��G��D�J����(�3�t�9�9�4���#������� P� P�Q�Q�Q�Q�Qr/rTc�(�|jrJ||jkrt|||j���||jz
}|j�||��\}}n�|jt
��z}|td||jz
��|�}t|||j��}	tdt||jdz��dz��D]F}
	|�|t|��|
z
��\}}n#t$r}|}	Yd}~�?d}~wwxYw|	�||fSr�)rr�r�rr�r"r�r
rpr�rBrm)r+r�r�rr�r?r5�	test_expr�instring_slice�	last_expr�offset�pbes            r-rHzPrecededBy.parseImpl&sA���:�	 ��T�\�!�!�$�X�s�D�K�@�@�@��$�,�&�E��Y�%�%�h��6�6�F�A�s�s��	�I�K�K�/�I�%�c�!�S�4�<�-?�&@�&@�3�&F�G�N�&�x��d�k�B�B�I���3�s�D�L�1�,<�#=�#=��#A�B�B�
 �
 ���&�-�-�&��N�(;�(;�f�(D���F�A�s��E��*�$�$�$� #�I�I�I�I�I�I�����$����
 ���C�x�s�
)C5�5
D�?D�Dr))rT)
r2r7r8rGrr�r�r�r�r�r.rHr�r�s@r-r�r��s����������<PT�R�R��-��,�-�R�8>���8L�R�R�R�R�R�R�2�������r/r�c��eZdZdZdd�ZdS)�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]

    Tc��|}|j�|||d���\}}t|||g��}||d<||d<||d<|jr||gfS||fS)NFr��
locn_startrr�locn_end)r�r"r r�)r+r�r�rr�r[r]s       r-rHzLocated.parseImpl\s~�����i�&�&�x��	�PU�&�V�V���V�!�5�&�#�"6�7�7�
�#(�
�<� �$�
�7��!$�
�:����	#����$�$��
�?�"r/Nr�)r2r7r8rGrHr9r/r-r�r�@s2��������6#�#�#�#�#�#r/r�c�F��eZdZdZdeeeff�fd�Zdd�Zd�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���t���|��d|_d|_dt	|j��z|_dS)NFTzFound unwanted token, )r�r.r�r�r�r�rr�s  �r-r.zNotAny.__init__�sE���
���������$���"���.��T�Y���?����r/Tc�n�|j�||��rt|||j|���|gfSr))r�rer�rrGs    r-rHzNotAny.parseImpl�s<���9�#�#�H�c�2�2�	C� ��3���T�B�B�B��B�w�r/c�6�dt|j��zdzS)Nz~{r�r�r�r�s r-rzNotAny._generateDefaultName�s���c�$�)�n�n�$�s�*�*r/r�)r2r7r8rGrr�r�r.rHrr�r�s@r-r�r�js����������0@�U�=�#�#5�6�@�@�@�@�@�@�����
+�+�+�+�+�+�+r/r�c���eZdZ	d
dd�dedejeeefdejeeeff�fd�Zdefd�Z	dd
�Z
d�fd�	Z�xZS)rfN��stopOnr��stop_onr�c����t���|��|p|}d|_|}t|t��r|�|��}|�|��dSr$)r�r.r�rSr#r�r�)r+r�r�r��enderr�s     �r-r.z_MultipleMatch.__init__�sp���	����������"�7��������e�X�&�&�	4��,�,�U�3�3�E����E�����r/rXc�r�t|t��r|�|��}|�|nd|_|Sr))rSr#r��	not_ender)r+r�s  r-r�z_MultipleMatch.stopOn�s>���e�X�&�&�	4��,�,�U�3�3�E�#(�#4�%���$����r/Tc�t�|jj}|j}|jdu}|r|jj}|r|||��||||��\}}	|j}		|r|||��|	r
|||��}
n|}
|||
|��\}}|s|���r||z
}�K#ttf$rYnwxYw||fSr))	r�r"r?r�r�r�rr�rQ)r+r�r�r�self_expr_parse�self_skip_ignorables�check_ender�
try_not_enderr[�hasIgnoreExprsr��	tmptokenss            r-rHz_MultipleMatch.parseImpl�s-���)�*��#�3���n�D�0���	4� �N�3�M��	)��M�(�C�(�(�(�%�o�h��Y�?�?���V�
	�%)�%5�!5�5�N�	
(��1�!�M�(�C�0�0�0�!�!�1�1�(�C�@�@�F�F� �F�!0���6�9�!M�!M���Y��(�	� 1� 1� 3� 3�(��i�'�F�	
(���
�+�	�	�	��D�	�����F�{�s�
AB�B3�2B3Fc
���tjr�tj|jvr�|jg|j���zD]t}t
|t��r]|jrVtj|jvrCtj
d�d|t|��j
|j��d����ut���||��Sr�)rOr`rjrr�r&rSr�r�r�rSr�r�r2r�rr�s    �r-rz_MultipleMatch._setResultsName�s�����>�	��E��*�+�+��i�[�4�9�#4�#4�#6�#6�6�
�
���q�-�0�0���
��$�M��/�0�0��M�E�EK�V�G� � ��J�J�/��M�	F�F�$%�	�	�	�	���w�w�&�&�t�^�<�<�<r/r)r�r~)
r2r7r8r�r�r�rr�r.r�rHrr�r�s@r-rfrf�s��������?C�
�
>B�
�
�
��
����}�c�'9�!:�;�
�
���m�S�&8� 9�:�
�
�
�
�
�
��}���������:=�=�=�=�=�=�=�=�=�=r/rfc��eZdZdZd�ZdS)r�ar
    Repetition of one or more of the given expression.

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

    Example::

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

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

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

        # could also be written as
        (attr_expr * (1,)).parse_string(text).pprint()
    c�6�dt|j��zdzS)Nrz}...r�r�s r-rzOneOrMore._generateDefaultName�����S���^�^�#�f�,�,r/N)r2r7r8rGrr9r/r-r�r��s-��������4-�-�-�-�-r/r�c���eZdZdZ	ddd�dedejeeefdejeeeff�fd�Z	d�fd	�	Z
d
�Z�xZS)
r�ao
    Optional repetition of zero or more of the given expression.

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

    Example: similar to :class:`OneOrMore`
    Nr�r�r�r�c�`��t���||p|���d|_dS)Nr�Tr�)r+r�r�r�r�s    �r-r.zZeroOrMore.__init__s5���	������f�&7���8�8�8�"����r/Tc���	t���|||��S#ttf$r|t	g|j���fcYSwxYw)Nr)r�rHr�rQr r�r�s    �r-rHzZeroOrMore.parseImplsj���	@��7�7�$�$�X�s�I�>�>�>���
�+�	@�	@�	@���R�d�.>�?�?�?�?�?�?�?�	@���s�"&�)A�Ac�6�dt|j��zdzS)N�[z]...r�r�s r-rzZeroOrMore._generateDefaultNamer�r/r)r�)
r2r7r8rGr�r�r�rr�r.rHrr�r�s@r-r�r�s��������
�
�?C�#�
>B�#�#�#��#����}�c�'9�!:�;�#�
���m�S�&8� 9�:�#�#�#�#�#�#�@�@�@�@�@�@�-�-�-�-�-�-�-r/r�c��eZdZd�Zd�ZdS)�
_NullTokenc��dSr�r9r�s r-�__bool__z_NullToken.__bool__$s���ur/c��dSrBr9r�s r-r z_NullToken.__str__'s���rr/N)r2r7r8rr r9r/r-r�r�#s2�������������r/r�c�b��eZdZdZe��Zefdeeefde	f�fd�
Z
dd�Zd�Z�xZ
S)	r�aN
    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���t���|d���|jj|_||_d|_dS)NFr�T)r�r.r�r��defaultValuer�)r+r�rr�s   �r-r.zOpt.__init__TsD���	��������.�.�.��)�.���#���"����r/Tc���|j}	|�|||d���\}}nO#ttf$r;|j}||jur&|jrt|g��}|||j<n|g}ng}YnwxYw||fS)NFr�)r�r"r�rQr�_Opt__optionalNotMatchedr�r )r+r�r�r�	self_exprr[�
default_values       r-rHz
Opt.parseImpl\s����I�	�	�#�*�*�8�S�)�RW�*�X�X�K�C�����
�+�		�		�		� �-�M��D�$=�=�=��(�-�)�=�/�:�:�F�4A�F�9�0�1�1�+�_�F�F�����		�����F�{�s�&�A	A2�1A2c��t|j��}t|��dkr[|ddt|��dz
�dkr<|dd�}t|��dkr|ddt|��dz
�dk�<d|zdzS)Nrrrr�r��])r�r�rBrs  r-rzOpt._generateDefaultNamels����D�I�����%�j�j�1�n�n��q�':�C��J�J��N�':�!;�t�!C�!C��!�B�$�K�E��%�j�j�1�n�n��q�':�C��J�J��N�':�!;�t�!C�!C��U�{�S� � r/r�)r2r7r8rGr�rrr�r�rr.rHrr�r�s@r-r�r�+s��������$�$�L&�:�<�<��?S�#�#��-��,�-�#�8;�#�#�#�#�#�#����� !�!�!�!�!�!�!r/r�c���eZdZdZ			d
dd�deeefdededej	eeefd	eeeff
�fd
�Z
dd�Z�xZS)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'
    FN)�failOnr��includer
�fail_onr
c�>��t���|��|p|}||_d|_d|_||_d|_t|t��r|�	|��|_
n||_
dt|j��z|_
dS)NTFzNo match found for )r�r.�
ignoreExprr�r�includeMatchr�rSr#r�r
r�r�r)r+r�rr
rr
r�s      �r-r.zSkipTo.__init__�s����	����������"�7�� ���"���"���#�������f�h�'�'�	!��2�2�6�:�:�D�K�K� �D�K�+�c�$�)�n�n�<����r/Tc��|}t|��}|jj}|j�|jjnd}|j�|jjnd}|}	|	|krd|�
|||	��rnl|� 		|||	��}	n#t$rYnwxYw�	|||	dd���n9#ttf$r|	dz
}	YnwxYw|	|k�dt|||j
|���|	}|||�}
t|
��}|jr||||d���\}}||z
}||fS)NrF)rrr�)
rBr�r"r
r�rr�rmr�rQrr r)
r+r�r�rr�rCr��self_failOn_canParseNext�self_ignoreExpr_tryParse�tmploc�skiptext�
skipresultrs
             r-rHzSkipTo.parseImpl�s������x�=�=���)�*��(,��(?�D�K�$�$�T�	!�)-��(C�D�O�$�$��	!����� � �'�3�+�+�H�f�=�=���'�3���!9�!9�(�F�!K�!K����-�����������
����&�E�PU�V�V�V�V���#�J�/�
�
�
��!�����
����!�� � �2!��3���T�B�B�B����H�S�L�)��!�(�+�+�
���	�&��x��i�e�T�T�T�H�C���#��J��J��s$�#A0�0
A=�<A=�B�B+�*B+)FNNr�)
r2r7r8rGrr�r�rr�r�r.rHr�r�s@r-r�r�ws��������:�:�~��>B�=�-1�=�=�=��]�C�'�(�=��=��	=�
���}�c�'9�!:�;�=��m�S�(�)�=�=�=�=�=�=�,0�0�0�0�0�0�0�0r/r�c����eZdZdZddejeeeff�fd�
Z	d�Z
d�Z�fd�Zd�Z
d�fd
�	Zddedefd
�Zddedefd�Zdefd�Zddd�Zd�Zdef�fd�Zd�fd�	ZeZeZ�xZS)rfaw
    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``.
    Nr�c���tjd���d|_t���|d���d|_dS)Nrkr�rFr�)r�r��caller_framer�r.�lshift_liner�s  �r-r.zForward.__init__sI���%�3�!�<�<�<�Q�?���
��������/�/�/�����r/c���t|d��r|`t|t��r|�|��}||_|jj|_|jj|_|�|jj	|jj
���|jj|_|jj|_|j
�|jj
��tjd���d|_|S)Nrr�rkr����)r#rrSr#r�r�rr�r	r�r�r�r�r�r�r�r�rr�s  r-�
__lshift__zForward.__lshift__s����4��(�(�	"��!��e�X�&�&�	4��,�,�U�3�3�E���	�!�Y�4���"�i�6����!�!��I� ��	�0O�	"�	
�	
�	
�#�i�6����)�.��������	� 5�6�6�6�$�2��;�;�;�B�?����r/c��||zSr)r9r�s  r-�__ilshift__zForward.__ilshift__0s���u�}�r/c���tjd���d}tjr4||jkr)t
j|jvrtjdd���t���
|��}|S)Nrkr�rz<using '<<' operator with '|' is probably an error, use '<<='r�)r�r�rOrerrjrr�rSr�r�)r+r��caller_liner5r�s    �r-r�zForward.__or__3s�����-�A�6�6�6�r�:���=�		��t�/�/�/��D��*�+�+�
�M�N��
�
�
�
��g�g�n�n�U�#�#���
r/c��|j�RtjrHtj|jvr7tjdt|jj	|jj
���dSdSdSdS)NzIForward defined here but no expression attached later using '<<=' or '<<')�filenamer�)r�rOrcrjrr��
warn_explicit�UserWarningrr%r�r�s r-�__del__zForward.__del__Bsx��
�I���6�
��9��AX�X�X��"�[���*�3��(�/�	
�
�
�
�
�
�	
����X�Xr/Tc	���|j��tjrxtj|jvregd�}tjd���}tt|��d���D]\}}|j	|vr|dz}n�d}tjd|���tj
s#t���|||��Stj5tj}		|	|||f\}
}t%|t&��r|�|
|���fcddd��S#t*$�rJ||d	f}||d
f}
|dz
t-||d|��fx\}
}|	|
<|r|	|
|	|<		t���||d
��\}}n*#t,$rt%|t&��r�|
|}}YnwxYw||
krc|r:|	|x\}
}|	|
<|	|
=|	|=|
|���fcYcddd��S|	|
=|
|���fcYcddd��S|rG	t���||d	��|	|<n#t,$r}||fx|	|
<|	|<�d}~wwxYw||fx\}
}|	|
<��wxYw#1swxYwYdS)N)r�r�r�r���r�r)r�rkzGForward expression was never assigned a value, will not parse any inputr�TFz#Forward recursion without base case)r�rOrbrjrr�r�r��reversedrUr�rSr�r{r�rHr�rgrSrRr�KeyErrorr�)r+r�r�r�	parse_fnsr�r|�frmr��memo�prev_loc�prev_result�act_key�peek_key�	prev_peek�new_loc�new_peekr=r�s                  �r-rHzForward.parseImplPs����I���:�
��=��*�+�+����I��(�s�3�3�3�B�#�H�R�L�L��:�:�:�
�
���3��8�y�(�(�!"�Q��J��E�)��
��M�Y�%�
�
�
�
��4�	?��7�7�$�$�X�s�I�>�>�>�(�
)�/	Q�/	Q� �0�D�-
Q�(,�S�$�	�-A�(B�%��+��k�9�5�5�&�%�%���!1�!1�!3�!3�3�/	Q�/	Q�/	Q�/	Q�/	Q�/	Q�/	Q�/	Q���'
Q�'
Q�'
Q���d�+����u�-���!�G�"� �#�'L�d���8��#��)�d�8�n��3�$(��N�D��M�Q�@�,1�G�G�,=�,=�h��U�,S�,S�)�����)�@�@�@�%�i��;�;�"�!�,4�i�����	@�����(�*�*�$�@�FJ�'�]�R�1�H�k�D��N� $�X���W�
�#+�[�-=�-=�-?�-?�#?�?�?�I/	Q�/	Q�/	Q�/	Q�/	Q�/	Q�/	Q�/	Q�J!��N�'����)9�)9�9�9�9�M/	Q�/	Q�/	Q�/	Q�/	Q�/	Q�/	Q�/	Q�R%�&�&�05���0A�0A�(�C�QU�0V�0V��W�
�
��#1�&�&�&�BI�1�� M��X���g�� %�����&����@G��?P�P�+��)�d�8�n�5Q�'
Q����/	Q�/	Q�/	Q�/	Q����/	Q�/	Q�/	Q�/	Q�/	Q�/	Qs��
I5�:D�AI2� &F�I2�$F.�+I2�-F.�.7I2�%I5�3I2�I5�I2�&I�I2�
I �
I�I � I2�2I5�5I9�<I9rrXc��d|_|Sr�rrs  r-rzForward.leave_whitespace�s��#����r/c��d|_|Sr$rrs  r-rzForward.ignore_whitespace�s��"����r/c�b�|js'd|_|j�|j���|Sr$)r�r�r�r�s r-r�zForward.streamline�s6����	'�#�D���y�$��	�$�$�&�&�&��r/c��|�g}||vr/|dd�|gz}|j�|j�|��|�g��dSr)r�r�s   r-r/zForward.validate�se��� ��M��}�$�$�����"�d�V�+�C��y�$��	�"�"�3�'�'�'����R� � � � � r/c��d|_d}	|j�t|j��dd�}nd}|jjdz|zS#|jjdz|zccYSxYw)Nz: ...r�i��Nonez: )r�r�r�r�r2)r+�	retStrings  r-rzForward._generateDefaultName�sz��#����	�	>��y�$���	�N�N�5�D�5�1�	�	�"�	��>�*�T�1�I�=�=��4�>�*�T�1�I�=�=�=�=�=�=�=�=�=s�&A�Ac�|��|j� t�����St��}||z}|Sr))r�r�rrfr�s  �r-rzForward.copy�s4����9� ��7�7�<�<�>�>�!��)�)�C��D�L�C��Jr/Fc	���tjrWtj|jvrD|j�=tjd�d|t|��j	��d���t���||��S)NzO{}: setting results name {!r} on {} expression that has no contained expressionrar$r�)rOrarjrr�r�rSr�r�r2r�r)r+rUrr�s   �r-rzForward._setResultsName�s�����3�	��:��*�+�+��y� ��
�7�7=�v�8�$��T�
�
�@S�8�8� !������w�w�&�&�t�-=�>�>�>r/r)r�r^r~)r2r7r8rGr�r�rr�r�r.rr!r�r(rHrrrr�r/rrrr�r�r�r�s@r-rfrf�s����������8 � �f�o�e�M�3�4F�.G�H� � � � � � �
���"���
�
�
�
�
����]Q�]Q�]Q�]Q�]Q�]Q�~��$��-�������4��=������M�����!�!�!�!�!�>�>�>��m�������?�?�?�?�?�?�")��&�O�O�O�O�Or/rfc�:��eZdZdZddeeeff�fd�
Z�xZS)�TokenConverterzW
    Abstract subclass of :class:`ParseExpression`, for converting parsed results.
    Fr�c�X��t���|��d|_dSr�)r�r.r�r�s   �r-r.zTokenConverter.__init__�s&���
�������������r/r~)	r2r7r8rGrr�r�r.r�r�s@r-rArA�s]��������� � �U�=�#�#5�6� � � � � � � � � � r/rAc�l��eZdZdZ		ddd�dededed	ejef�fd
�Z	def�fd�Z
d
�Z�xZS)�Combinea�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...)
    r~TN)�
joinStringr��join_string�adjacentrEc���t���|��|�|n|}|r|���||_d|_||_d|_dSr$)r�r.rrGr�rEr)r+r�rFrGrEr�s     �r-r.zCombine.__init__si���	���������#-�#9�Z�Z�{�
��	$��!�!�#�#�#� ��
�"���$��� ����r/rXc���|jrt�||��n!t���|��|Sr))rGr�r
r�r�s  �r-r
zCombine.ignore"sA����=�	"�� � ��u�-�-�-�-��G�G�N�N�5�!�!�!��r/c��|���}|dd�=|td�|�|j����g|j���z
}|jr|���r|gS|S)Nr~)rP)rr r��
_asStringListrErr�r)r+r�r�rK�retTokss     r-rLzCombine.postParse)s����.�.�"�"���A�A�A�J��<�
�W�W�Y�,�,�T�_�=�=�
>�
>�?�t�GX�
�
�
�	
����	���� 1� 1�	��9���Nr/)r~T)
r2r7r8rGr�r�rr�r�r.r
rLr�r�s@r-rDrD�s����������*��	!�,0�
!�!�!��!��!��	!��O�C�(�
!�!�!�!�!�!�$�}�������
�
�
�
�
�
�
r/rDc�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(delimited_list(term))
        print(func.parse_string("fn a, b, 100"))
        # -> ['fn', 'a', 'b', '100']

        func = ident + Group(Opt(delimited_list(term)))
        print(func.parse_string("fn a, b, 100"))
        # -> ['fn', ['a', 'b', '100']]
    Fr��aslistc�f��t���|��d|_||_dSr$)r�r.r��
_asPythonList)r+r�rNr�s   �r-r.zGroup.__init__K�0���
������������#����r/c��|jrJtjt|t��r|���nt|����S|gSr))rPr r	rSrOr�rJs    r-rLzGroup.postParsePsX����	��$��i��6�6�%�	� � �"�"�"��)�_�_���
��;�r/r~�	r2r7r8rGr�rr.rLr�r�s@r-r�r�6si���������($�$�]�$�D�$�$�$�$�$�$�
������r/r�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.
    Fr��asdictc�f��t���|��d|_||_dSr$)r�r.r��
_asPythonDict)r+r�rUr�s   �r-r.z
Dict.__init__�rQr/c�~�t|��D�]j\}}t|��dkr�|d}t|t��r!t	|�����}t|��dkrt
d|��||<�t|��dkr5t|dt��st
|d|��||<��	|���}n #t$rtd��}|d�wxYw|d=t|��dks)t|t��r)|���rt
||��||<��Qt
|d|��||<��l|jr0|j
r|���gn|���S|j
r|gn|S)Nrrr~rkzdcould not extract dict values from parsed results - Dict expression must contain Grouped expressions)r�rBrSr�r�rZr!r rrRr�rrWr��as_dict)	r+r�r�rKr|�tok�ikey�	dictvaluer�s	         r-rLzDict.postParse�s����	�*�*�	O�	O�F�A�s��3�x�x�1�}�}���q�6�D��$��$�$�
)��4�y�y���(�(���3�x�x�1�}�}�"9�"�a�"@�"@�	�$����S���Q���z�#�a�&�,�'G�'G��"9�#�a�&�!�"D�"D�	�$���(� #���
�
�I�I�� �(�(�(�#�N���C��4�'�(�����a�L��y�>�>�Q�&�&��y�,�7�7�'�<E�<M�<M�<O�<O�'�'>�i��&K�&K�I�d�O�O�&=�i��l�A�&N�&N�I�d�O�O���	B�,0�,<�U�I�%�%�'�'�(�(�)�BS�BS�BU�BU�U�"&�"2�A�I�;�;�	�As�C-�-D
r~rSr�s@r-r�r�[sq�������'�'�R$�$�]�$�D�$�$�$�$�$�$�
%B�%B�%B�%B�%B�%B�%Br/r�c�h��eZdZdZddeeefdef�fd�
Zd
�fd�Z	d
�fd	�Z
d
�Zdefd�Z�xZ
S)r�a�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:`delimited_list`.)
    Fr�r�c���|durtt����}t���|��dS)N.)r�r�r�r.r�s   �r-r.zSuppress.__init__�s;����3�;�;���	�	�*�*�D�
����������r/rXr�c���t|jt��rtt	|����|zSt���|��Sr))rSr�r�r�r�r�r�r�s  �r-r�zSuppress.__add__��F����d�i��.�.�	*��F�5�M�M�*�*�U�2�2��7�7�?�?�5�)�)�)r/c���t|jt��rtt	|����|z
St���|��Sr))rSr�r�r�r�r�r�r�s  �r-r�zSuppress.__sub__�r`r/c��gSr)r9rJs    r-rLzSuppress.postParse�r'r/c��|Sr)r9r�s r-r�zSuppress.suppress�s���r/r~r)r2r7r8rGrr�r�rr.r�r�rLr�r�r�s@r-r�r��s����������<��U�=�#�#5�6��$�������
*�*�*�*�*�*�*�*�*�*�*�*�����-��������r/r�r:c�H��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|��dkr|djjdz|z}tj�d�|t||��||����	�|�}nF#t$r9}tj�d�||�����d}~wwxYwtj�d�||����|S)N���r$r�.z$>>entering {}(line: {!r}, {}, {!r})
z<<leaving {} (exception: {})
z<<leaving {} (ret: {!r})
)	r2rBr�r^�stderrr`r�r�rR)�paArgs�thisFuncr�r�r�r5r�r:s       �r-�zztrace_parse_action.<locals>.zs	����:������+���1�a��v�;�;��?�?��a�y�*�3�c�9�H�D�H��
���3�:�:�8�T�!�Q�Z�Z�QR�TU�V�V�	
�	
�	
�	��!�V�*�C�C���	�	�	��J���=�D�D�X�s�S�S�T�T�T������	����	�
���5�<�<�X�s�K�K�L�L�L��
s�B�
C�4C
�
C)r�r2)r:rks` r-�trace_parse_actionrl�s9���2	�A���A������ ��A�J��Hr/�empty�
line_start�line_end�string_start�
string_endz\[]-*.$+^?()~ rk)rc��|ddSr�r9r�s   r-r�r� s��A�a�D��G�r/z\\0?[xX][0-9a-fA-F]+c�n�tt|d�d��d����S)Nrz\0xr$)�chrr�rcr�s   r-r�r�#s(��C��A�a�D�K�K��/�/��4�4�5�5�r/z	\\0[0-7]+c�X�tt|ddd�d����S)Nrrr%)rtr�r�s   r-r�r�&s$��C��A�a�D����H�a�(�(�)�)�r/z\]r�r��^�negate�bodyrr�c���d��	d��fd�t�|��jD����S#t$rYdSwxYw)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|nUd�d�tt	|d��t	|d��dz��D����S)Nr~c3�4K�|]}t|��V��dSr))rtr�s  r-r*z+srange.<locals>.<lambda>.<locals>.<genexpr>Qs(����E�E��S��V�V�E�E�E�E�E�Er/rr)rSr r�rp�ord)�ps r-r�zsrange.<locals>.<lambda>Os^���!�\�*�*�F�!�!�
�W�W�E�E�U�3�q��t�9�9�c�!�A�$�i�i�!�m�%D�%D�E�E�E�
E�
E�r/r~c3�.�K�|]}�|��V��dSr)r9)rC�part�	_expandeds  �r-r*zsrange.<locals>.<genexpr>Ts+�����W�W�4�y�y����W�W�W�W�W�Wr/)r��_reBracketExprr�rxrR)r�r�s @r-�sranger�4ss���6	F�	F��
��w�w�W�W�W�W�>�3N�3N�q�3Q�3Q�3V�W�W�W�W�W�W�������r�r����s�=A�
A�Ac�l�����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�"����fd�|D��S)Nc�"��g|]}�|g��R���Sr9r9)rC�toknr�r,s  ��r-rEz)token_map.<locals>.pa.<locals>.<listcomp>s+���0�0�0�d���T�!�D�!�!�!�0�0�0r/r9)r�r�r�r�r,s   ��r-r�ztoken_map.<locals>.pa~s ���0�0�0�0�0�a�0�0�0�0r/r2r�)r�r2)r,r�r�r�s``  r-�	token_mapr�YsO����J1�1�1�1�1�1���j�'�$��*D�*D�*M�N�N�I��B�K�
�Ir/c���tj��jj���D]6\}}t|t��r|js|�|���7dS)zy
    Utility to simplify mass-naming of parser elements, for
    generating railroad diagram with named subdiagrams.
    N)	r^�	_getframe�f_back�f_localsrGrSr�r�r)rU�vars  r-�autoname_elementsr��sg��
�]�_�_�+�4�:�:�<�<���	��c��c�=�)�)�	�#�.�	��L�L�������r/z4"(?:[^"\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 quotesz*quotedString using single or double quotes�uzunicode string literalz#[\0xc0-\0xd6\0xd8-\0xf6\0xf8-\0xff]z[\0xa1-\0xbf\0xd7\0xf7]c�<�g|]}t|t���|��Sr9)rSr�)rCrJs  r-rErE�s7��'�'�'�
�*�Q�
�">�">�'��'�'�'r/r�r^)r$r�r~)��osr�rrrrrrr	r
rr�abcr
r�enumrr�rr�rr^�collections.abcrr��types�operatorr�	functoolsr�	threadingr�pathlibr�utilrrrrrrrrr�rr��
exceptions�actionsrr r!�unicoder"�maxsizer�r��bytesr#r�r��version_infor&r;rOrjrsrvr]r�rr��warnoptions�environr/�sumrBrr+r�r�r�r�r.r�r
r��
GeneratorTyper�r�r�r�rRr�r�r�r��ascii_uppercase�ascii_lowercase�alphas�Latin1�
identchars�identbodychars�nums�hexnumsr�r��	printabler�r��StackSummaryr�r�r�r�r�r�r�r�r�r�r�r]r�r�r�r�r�r�rrr0r4rWr{r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rfr�r�r�r�r�rfrArDr�r�r�rlrrmrnrorprqr2�_escapedPunc�_escapedHexChar�_escapedOctChar�_singleChar�
_charRangerr�r�r�r��dbl_quoted_string�sgl_quoted_stringrb�unicode_string�
alphas8bit�punc8bitr>�valuesr��tokenMap�conditionAsParseAction�nullDebugAction�sglQuotedString�dblQuotedString�quotedString�
unicodeString�	lineStart�lineEnd�stringStart�	stringEnd�traceParseActionr9r/r-�<module>r�s��
�	�	�	�	�
�
�
�
�������������������������$�#�#�#�#�#�#�#�������
�
�
�
���������	�	�	�	�
�
�
�
�$�$�$�$�$�$���������������������������������
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
���������:�:�:�:�:�:�:�:�&�&�&�&�&�&��;��!�5�\��%��c�	�
�)�)�)�4��v���)�)�)�)�)�)�)������������������.�����~����,*�*�*�*�*�$�*�*�*�B$�;�$�4�$�$�$�$�%�K�%�D�%�%�%�%�#�#�#�#���!�?�3�/��?E��s�?S��	�����"���O�R�Z�^�^�$@�A�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��
�
%�
0�
�"�)�8����
��
���T�M�	�
�W�W�P�P��!1�P�P�P�
Q�
Q�
�04��y�-�4�4�4�9�9�9�9�z<A�����!$��48�������:GL�������#2��?C�����2�
	L�	L��	L��	L�
�	L��		L�
�	L��
	L�	L�	L�	L�"�����	����
�	�
�����R�R�R�Y'�Y'�Y'�Y'�Y'�C�Y'�Y'�Y'�x8&
�&
�&
�&
�&
�=�&
�&
�&
�R	#�	#�	#�	#�	#�M�	#�	#�	#�#�#�#�#�#�E�#�#�#�?�?�?�?�?�e�?�?�?�*?�*?�*?�*?�*?�e�*?�*?�*?�Z?�?�?�?�?��?�?�?�%,�
�!�s7�s7�s7�s7�s7�e�s7�s7�s7�l?�?�?�?�?�g�?�?�?�6B�B�B�B�B�g�B�B�B�2V?�V?�V?�V?�V?��V?�V?�V?�rm(�m(�m(�m(�m(�5�m(�m(�m(�`#�#�#�#�#��#�#�#�&�&�&�&�&�:�&�&�&�6X)�X)�X)�X)�X)�E�X)�X)�X)�vA�A�A�A�A�5�A�A�A�HM(�M(�M(�M(�M(��M(�M(�M(�`J(�J(�J(�J(�J(�E�J(�J(�J(�Z#�#�#�#�#�E�#�#�#����������>,?�,?�,?�,?�,?�
�,?�,?�,?�^C�C�C�C�C�m�C�C�C�.�����-����"C�C�C�C�C�
�C�C�C�(�����
����4�����m����6^'�^'�^'�^'�^'�m�^'�^'�^'�BW!�W!�W!�W!�W!�/�W!�W!�W!�tX=�X=�X=�X=�X=��X=�X=�X=�vl=�l=�l=�l=�l=��l=�l=�l=�^dB�dB�dB�dB�dB�?�dB�dB�dB�NZ'�Z'�Z'�Z'�Z'�-�Z'�Z'�Z'�z=
�=
�=
�=
�=
�'�=
�=
�=
�@;�;�;�;�;�'�;�;�;�*;�;�;�;�;�%�;�;�;�B!�!�!�!�!�$�!�!�!�HN�N�N�N�N�$�N�N�N�b'#�'#�'#�'#�'#�!�'#�'#�'#�T(+�(+�(+�(+�(+�
 �(+�(+�(+�VK=�K=�K=�K=�K=�(�K=�K=�K=�\-�-�-�-�-��-�-�-�>-�-�-�-�-��-�-�-�B��������F!�F!�F!�F!�F!�
�F!�F!�F!�R��C�C�C�C�C�
 �C�C�C�Ls'�s'�s'�s'�s'�!�s'�s'�s'�l � � � � �(� � � �6�6�6�6�6�n�6�6�6�r"�"�"�"�"�N�"�"�"�JTB�TB�TB�TB�TB�>�TB�TB�TB�n4�4�4�4�4�~�4�4�4�n,
�+�,
�+�,
�,
�,
�,
�`	�������!�!��
�Y�[�[�
!�
!�,�
/�
/�
��7�9�9���j�)�)���{�}�}�%�%�n�5�5��
�Y�[�[�
!�
!�,�
/�
/�
��t�G�.�a�8�8�8�I�I�������%�/�0�0�A�A�5�5�����%��%�%�6�6�)�)�����?�"�_�4�z�z�%�q�7Q�7Q�7Q�Q���U�;���#���.��<�
=�
=�
��G�C�L�L�	�c�#�h�h����)�)�*��e�I�I�j�;�.�/�/�0�0�A�A�&�I�I�J�
�
��"�c�"�c�"�"�"�"�J+�k�+�+�+�+�\�����G�	�E�
A�B�B�S�H���
�(�-�.�.���G�	�E�
A�B�B�S�H���
�(�-�.�.����	�E�
A�B�B�S�H��e�C�D�D�s�J�K����(�7�8�8��
���}�1�1�3�3�3�4�4�=�=�>V�W�W���V�:�
;�
;�
��6�,�-�-��'�'��t�v�v�}�}���'�'�'���]�#����
��2��#��#��#�����
��	�
�����	�%���r/