%PDF- %PDF-
Mini Shell

Mini Shell

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

�

&
�d�����UddlZddlZddlZddlZddlmZddl�ddlm	Z	m
Z
mZmZ	dcdd�de
deje
d	eje
d
e
fd�Zde
d
e
fd�Zde
d
e
fd
�Z			ddddd�deej&eefdededededed
e
fd�Zde
de
d
e
fd�Z	dedd�de
deded
e
fd�Zde
d
e
fd�Zde
d
e
fd �Zd!d"de�fe�d#�d$eee
fd%eee
fd&eje
d'e
d(e
d
e
fd)�Zed*�ed+�fd,�Zd-eee
fd
ee
e
ffd.�Z d-eee
fd
ee
e
ffd/�Z!e
e"d0<e
e"d1<e e#e$e%d2z�jMd3��\Z'Z(ejRjTjW�D��cic]\}}|jYd4�|��c}}Z-e.d5d6j_e-�zd7z�jMd8�Z0d9�Z1Gd:�d;e2�Z3ee
eeee
efee
efffZ4eee4e5e3eje6fee4e5e3ffZ7ed!�ed"�fd<e
d=e8e7d>eee
fd?eee
fd
e
f
d@�Z9dgfdA�Z:e;e.dB�dCz�jMdD�Z<	e.dE�jMdF�Z=	e.dG�j}�jMdH�Z?e.dI�jMdJ�Z@	e;e.dB�dCze@z�jMdK�ZA	eAZB	e.dL�jMdM�ZC	eD�j��D�cgc]}eF|e
�s�
|��c}ZGe8e
e"dN<				dfddO�deee
fdPeee
fdQedReje5dSeje5dTed
e
fdU�ZHe3ZIe'ZJe(ZKe0ZLe<ZMe=ZNe?ZOe@ZPeAZQeBZReCZSeeT�dV��ZUeeT�dW��ZHee�dX��ZVee�dY��ZWee�dZ��ZXee�d[��ZYee�d\��ZZee�d]��Z[ee�d^��Z\ee �d_��Z]ee!�d`��Z^ee1�da��Z_ee9�db��Z`ycc}}wcc}w)g�N�)�__diag__)�*)�_bslash�_flatten�_escape_regex_range_chars�replaced_by_pep8)�intExpr�expr�int_exprr
�returnc�$���|xs|}t����fd�}|� tt�jd��}n|j	�}|jd�|j
|d��|�zjdt��zdz�S)a~Helper to define a counted list of expressions.

    This helper defines a pattern of the form::

        integer expr expr expr...

    where the leading integer tells how many expr expressions follow.
    The matched tokens returns the array of expr tokens as a list - the
    leading count token is suppressed.

    If ``int_expr`` is specified, it should be a pyparsing expression
    that produces an integer value.

    Example::

        counted_array(Word(alphas)).parse_string('2 ab cd ef')  # -> ['ab', 'cd']

        # in this parser, the leading integer value is given in binary,
        # '10' indicating that 2 values are in the array
        binary_constant = Word('01').set_parse_action(lambda t: int(t[0], 2))
        counted_array(Word(alphas), int_expr=binary_constant).parse_string('10 ab cd ef')  # -> ['ab', 'cd']

        # if other fields must be parsed after the count but before the
        # list items, give the fields results names and they will
        # be preserved in the returned ParseResults:
        count_with_metadata = integer + Word(alphas)("type")
        typed_array = counted_array(Word(alphanums), int_expr=count_with_metadata)("items")
        result = typed_array.parse_string("3 bool True True False")
        print(result.dump())

        # prints
        # ['True', 'True', 'False']
        # - items: ['True', 'True', 'False']
        # - type: 'bool'
    c�B��|d}�|r�|zn	t�z�|dd�=y�Nr)�Empty)�s�l�t�n�
array_exprrs    ���3/usr/lib/python3/dist-packages/pyparsing/helpers.py�count_field_parse_actionz/counted_array.<locals>.count_field_parse_action@s'���
�a�D���Q��q��E�G�3�
�
�a�D�c��t|d�Sr)�int�rs r�<lambda>zcounted_array.<locals>.<lambda>Hs���A�a�D�	�r�arrayLenT)�call_during_tryz(len) z...)�Forward�Word�nums�set_parse_action�copy�set_name�add_parse_action�str)rrr
rrs`   @r�
counted_arrayr(s����R�!��G���J�����t�*�-�-�.A�B���,�,�.�����Z� ����5�t��L��j� �*�*�8�c�$�i�+?�%�+G�H�Hrc���t���fd�}|j|d���jdt|�z��S)a9Helper to define an expression that is indirectly defined from
    the tokens matched in a previous expression, that is, it looks for
    a 'repeat' of a previous expression.  For example::

        first = Word(nums)
        second = match_previous_literal(first)
        match_expr = first + ":" + second

    will match ``"1:1"``, but not ``"1:2"``.  Because this
    matches a previous literal, will also match the leading
    ``"1:1"`` in ``"1:10"``. If this is not desired, use
    :class:`match_previous_expr`. Do *not* use with packrat parsing
    enabled.
    c���|rFt|�dk(r	�|dzyt|j��}�td�|D��zy�t	�zy)Nrrc3�2K�|]}t|����y�w�N)�Literal)�.0�tts  r�	<genexpr>zImatch_previous_literal.<locals>.copy_token_to_repeater.<locals>.<genexpr>hs����7�2�7�2�;�7���)�lenr�as_list�Andr)rrr�tflat�reps    �r�copy_token_to_repeaterz6match_previous_literal.<locals>.copy_token_to_repeaterasJ�����1�v��{��q��t��!�����-���s�7��7�7�7��5�7�NrT��
callDuringTry�(prev) )r r&r%r')rr7r6s  @r�match_previous_literalr;PsA����)�C�	�	���0���E��L�L��S��Y�&�'��Jrc���t��|j�}�|z��fd�}|j|d���jdt	|�z��S)aWHelper to define an expression that is indirectly defined from
    the tokens matched in a previous expression, that is, it looks for
    a 'repeat' of a previous expression.  For example::

        first = Word(nums)
        second = match_previous_expr(first)
        match_expr = first + ":" + second

    will match ``"1:1"``, but not ``"1:2"``.  Because this
    matches by expressions, will *not* match the leading ``"1:1"``
    in ``"1:10"``; the expressions are evaluated first, and then
    compared, so ``"1"`` is compared with ``"10"``. Do *not* use
    with packrat parsing enabled.
    c�j���t|j����fd�}�j|d��y)Nc�h��t|j��}|�k7rt||d��d|����y)Nz	Expected z, found)rr3�ParseException)rrr�theseTokens�matchTokenss    �r�must_match_these_tokenszTmatch_previous_expr.<locals>.copy_token_to_repeater.<locals>.must_match_these_tokens�sA���"�1�9�9�;�/�K��k�)�$��q�I�k�]�'�+��G���*rTr8)rr3r#)rrrrBrAr6s    @�rr7z3match_previous_expr.<locals>.copy_token_to_repeater�s.����q�y�y�{�+��	�	���4�D��IrTr8r:)r r$r&r%r')r�e2r7r6s   @r�match_previous_exprrDqsV����)�C�	
����B��B�J�C�
J�	���0���E��L�L��S��Y�&�'��JrFT)�useRegex�	asKeyword�strs�caseless�	use_regex�
as_keywordrErFc�H���|xs|}|xr|}t|t�r'tjrtjdd��|rd�}d�}|rtnt�nd�}d�}|rtnt�g}t|t�r+tjt|�}|j�}n't|t�rt|�}nt!d��|s
t#�St%d	�|D��r�d
}	|	t'|�dz
kro||	}
t)||	dzd�D]?\}}|||
�r||	|zdz=n-||
|�s�$||	|zdz=|j+|	|�n|	dz
}	|	t'|�dz
kr�o|r�|rt,j.nd
}
	t1d
�|D��rddj3d�|D���d�}ndj3d�|D��}|rd|�d�}t5||
��j7dj3|��}|r3|D�cic]}|j9�|��c}�|j;�fd��|St?�fd�|D��j7dj3|��Scc}w#t,j<$rtjdd��Y�cwxYw)a!Helper to quickly define a set of alternative :class:`Literal` s,
    and makes sure to do longest-first testing when there is a conflict,
    regardless of the input order, but returns
    a :class:`MatchFirst` for best performance.

    Parameters:

    - ``strs`` - a string of space-delimited literals, or a collection of
      string literals
    - ``caseless`` - treat all literals as caseless - (default= ``False``)
    - ``use_regex`` - as an optimization, will
      generate a :class:`Regex` object; otherwise, will generate
      a :class:`MatchFirst` object (if ``caseless=True`` or ``as_keyword=True``, or if
      creating a :class:`Regex` raises an exception) - (default= ``True``)
    - ``as_keyword`` - enforce :class:`Keyword`-style matching on the
      generated expressions - (default= ``False``)
    - ``asKeyword`` and ``useRegex`` are retained for pre-PEP8 compatibility,
      but will be removed in a future release

    Example::

        comp_oper = one_of("< = > <= >= !=")
        var = Word(alphas)
        number = Word(nums)
        term = var | number
        comparison_expr = term + comp_oper + term
        print(comparison_expr.search_string("B = 12  AA=23 B<=AA AA>12"))

    prints::

        [['B', '=', '12'], ['AA', '=', '23'], ['B', '<=', 'AA'], ['AA', '>', '12']]
    z`More than one string argument passed to one_of, pass choices as a list or space-delimited string�)�
stacklevelc�D�|j�|j�k(Sr,)�upper��a�bs  rrzone_of.<locals>.<lambda>�s��q�w�w�y�A�G�G�I�5�rc�\�|j�j|j��Sr,)rO�
startswithrPs  rrzone_of.<locals>.<lambda>�s��Q�W�W�Y�1�1�!�'�'�)�<�rc��||k(Sr,�rPs  rrzone_of.<locals>.<lambda>�s
��q�A�v�rc�$�|j|�Sr,)rTrPs  rrzone_of.<locals>.<lambda>�s��Q�\�\�!�_�rz7Invalid argument to one_of, expected string or iterablec3�8K�|]}t|�dkD���y�w�rN�r2�r.�syms  rr0zone_of.<locals>.<genexpr>�s����
+�C�3�s�8�a�<�
+���rrNc3�8K�|]}t|�dk(���y�wrYrZr[s  rr0zone_of.<locals>.<genexpr>�s����4�S�3�s�8�q�=�4�r]�[�c3�2K�|]}t|����y�wr,)rr[s  rr0zone_of.<locals>.<genexpr>�s����"U�c�#<�S�#A�"U�r1�]�|c3�FK�|]}tj|����y�wr,)�re�escaper[s  rr0zone_of.<locals>.<genexpr>�s����B�3��	�	�#��B�s�!z\b(?:z)\b)�flagsz | c�0���|dj�Sr��lower)rrr�
symbol_maps   �rrzone_of.<locals>.<lambda>s���Z��!��
�
��5M�rz8Exception creating Regex for one_of, building MatchFirstc3�.�K�|]}�|����y�wr,rV)r.r\�parseElementClasss  �rr0zone_of.<locals>.<genexpr>s�����@��'��,�@�s�) �
isinstance�str_typer�%warn_on_multiple_string_args_to_oneof�warnings�warn�CaselessKeyword�CaselessLiteral�Keywordr-�typing�castr'�split�Iterable�list�	TypeError�NoMatch�anyr2�	enumerate�insertre�
IGNORECASE�all�join�Regexr%rjr&�error�
MatchFirst)rGrHrIrJrErF�isequal�masks�symbols�i�cur�j�other�re_flags�patt�retr\rmrks                 @@r�one_ofr��s����R�'�Z�I��%�I�H�	�8�X�&��:�:��
�
�
;��	�	
��5��<��/8�O�o��%��,��'0�G�g���G��$��!��{�{�3��%���*�*�,��	�D�(�	#��t�*���Q�R�R���y���
+�7�
+�+�
���#�g�,��"�"��!�*�C�%�g�a�!�e�g�&6�7�	
���5��5�#�&���A���	�*���3��&���A���	�*��N�N�1�e�,��	
��Q����#�g�,��"�"��)1��
�
�q��	��4�G�4�4��2�7�7�"U�W�"U�U�V�VW�X���x�x�B�'�B�B�����v�S�)����H�-�6�6�u�z�z�'�7J�K�C��;B�B�3�c�i�i�k�3�.�B�
��$�$�%M�N��J��@��@�@�I�I�
�
�
�7�����C��
�x�x�	��M�M�J�WX�
�
�	�s%�BI4�I/�$I4�/I4�4*J!� J!�key�valuec�B�ttt||z���S)a�Helper to easily and clearly define a dictionary by specifying
    the respective patterns for the key and value.  Takes care of
    defining the :class:`Dict`, :class:`ZeroOrMore`, and
    :class:`Group` tokens in the proper order.  The key pattern
    can include delimiting markers or punctuation, as long as they are
    suppressed, thereby leaving the significant key text.  The value
    pattern can include named results, so that the :class:`Dict` results
    can include named token fields.

    Example::

        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(attr_expr[1, ...].parse_string(text).dump())

        attr_label = label
        attr_value = Suppress(':') + OneOrMore(data_word, stop_on=label).set_parse_action(' '.join)

        # similar to Dict, but simpler call format
        result = dict_of(attr_label, attr_value).parse_string(text)
        print(result.dump())
        print(result['shape'])
        print(result.shape)  # object attribute access works too
        print(result.as_dict())

    prints::

        [['shape', 'SQUARE'], ['posn', 'upper left'], ['color', 'light blue'], ['texture', 'burlap']]
        - color: 'light blue'
        - posn: 'upper left'
        - shape: 'SQUARE'
        - texture: 'burlap'
        SQUARE
        SQUARE
        {'color': 'light blue', 'shape': 'SQUARE', 'posn': 'upper left', 'texture': 'burlap'}
    )�Dict�	OneOrMore�Group)r�r�s  r�dict_ofr�s��J�	�%��e��,�-�.�.r)�asString�	as_stringr�c�0�|xr|}t�jd��}|j�}d|_|d�|z|d�z}|rd�}nd�}|j|�|j|_|jtj�|S)a
Helper to return the original, untokenized text for a given
    expression.  Useful to restore the parsed fields of an HTML start
    tag into the raw tag text itself, or to revert separate tokens with
    intervening whitespace back to the original matching input text. By
    default, returns a string containing the original parsed text.

    If the optional ``as_string`` argument is passed as
    ``False``, then the return value is
    a :class:`ParseResults` containing any results names that
    were originally matched, and a single token containing the original
    matched text from the input string.  So if the expression passed to
    :class:`original_text_for` contains expressions with defined
    results names, you must set ``as_string`` to ``False`` if you
    want to preserve those results name values.

    The ``asString`` pre-PEP8 argument is retained for compatibility,
    but will be removed in a future release.

    Example::

        src = "this is test <b> bold <i>text</i> </b> normal text "
        for tag in ("b", "i"):
            opener, closer = make_html_tags(tag)
            patt = original_text_for(opener + ... + closer)
            print(patt.search_string(src)[0])

    prints::

        ['<b> bold <i>text</i> </b>']
        ['<i>text</i>']
    c��|Sr,rV)r�locrs   rrz#original_text_for.<locals>.<lambda>_s��3�rF�_original_start�
_original_endc�4�||j|jSr,)r�r��rrrs   rrz#original_text_for.<locals>.<lambda>ds��a��(9�(9�A�O�O�&L�rc�R�||jd�|jd�g|ddy)Nr�r���popr�s   r�extractTextz&original_text_for.<locals>.extractTextgs(���a�e�e�-�.�����1G�H�I�A�a�Dr)rr#r$�callPreparse�ignoreExprs�suppress_warning�Diagnostics�)warn_ungrouped_named_tokens_in_collection)rr�r��	locMarker�endlocMarker�	matchExprr�s       r�original_text_forr�;s���D�%�I�H���(�(�)>�?�I��>�>�#�L� %�L���+�,�t�3�l�?�6S�S�I��L��	J����{�+� �,�,�I��
���{�T�T�U��rc�8�t|�jd��S)zkHelper to undo pyparsing's default grouping of And expressions,
    even if all but one are non-empty.
    c��|dSrrVrs rrzungroup.<locals>.<lambda>ts
��1�Q�4�r)�TokenConverterr&)rs r�ungroupr�ps���$��0�0��@�@rc��t�jd��}t|d�|d�z|j�j	�d�z�S)a
    (DEPRECATED - future code should use the :class:`Located` class)
    Helper to decorate 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 locatedExpr(wd).search_string("ljsdf123lksdjjf123lkkjj1222"):
            print(match)

    prints::

        [[0, 'ljsdf', 5]]
        [[8, 'lksdjjf', 15]]
        [[18, 'lkkjj', 23]]
    c��|Sr,rV)�ss�llr/s   rrzlocatedExpr.<locals>.<lambda>�s��"�r�
locn_startr��locn_end)rr#r�r$�leaveWhitespace)r�locators  r�locatedExprr�wsV��6�g�&�&�'<�=�G�����
�w�-�	�
*�'�,�,�.�
(�
(�
*�:�
6�	7��r�(�))�
ignoreExpr�opener�closer�content�ignore_exprr�c	���||k7r|t�k(r|n|}||k(rtd��|���t|t��r�t|t��r�t	j
t|�}t	j
t|�}t|�dk(r�t|�dk(r�|�Itt|t||ztjzd��z��jd��}�ntj�t||ztjz�jd��z}n�|�\tt|t!|�zt!|�zttjd��z��jd��}ncttt!|�t!|�zttjd��z��jd��}ntd��t#�}|�6|t%t'|�t)||z|z�zt'|�z�z}n2|t%t'|�t)||z�zt'|�z�z}|j+d	|�|�d
��|S)a&
Helper method for defining nested lists enclosed in opening and
    closing delimiters (``"("`` and ``")"`` are the default).

    Parameters:

    - ``opener`` - opening character for a nested list
      (default= ``"("``); can also be a pyparsing expression
    - ``closer`` - closing character for a nested list
      (default= ``")"``); can also be a pyparsing expression
    - ``content`` - expression for items within the nested lists
      (default= ``None``)
    - ``ignore_expr`` - expression for ignoring opening and closing delimiters
      (default= :class:`quoted_string`)
    - ``ignoreExpr`` - this pre-PEP8 argument is retained for compatibility
      but will be removed in a future release

    If an expression is not provided for the content argument, the
    nested expression will capture all whitespace-delimited content
    between delimiters as a list of separate values.

    Use the ``ignore_expr`` argument to define expressions that may
    contain opening or closing characters that should not be treated as
    opening or closing characters for nesting, such as quoted_string or
    a comment expression.  Specify multiple expressions using an
    :class:`Or` or :class:`MatchFirst`. The default is
    :class:`quoted_string`, but if no expressions are to be ignored, then
    pass ``None`` for this argument.

    Example::

        data_type = one_of("void int short long char float double")
        decl_data_type = Combine(data_type + Opt(Word('*')))
        ident = Word(alphas+'_', alphanums+'_')
        number = pyparsing_common.number
        arg = Group(decl_data_type + ident)
        LPAR, RPAR = map(Suppress, "()")

        code_body = nested_expr('{', '}', ignore_expr=(quoted_string | c_style_comment))

        c_function = (decl_data_type("type")
                      + ident("name")
                      + LPAR + Opt(DelimitedList(arg), [])("args") + RPAR
                      + code_body("body"))
        c_function.ignore(c_style_comment)

        source_code = '''
            int is_odd(int x) {
                return (x%2);
            }

            int dec_to_hex(char hchar) {
                if (hchar >= '0' && hchar <= '9') {
                    return (ord(hchar)-ord('0'));
                } else {
                    return (10+ord(hchar)-ord('A'));
                }
            }
        '''
        for func in c_function.search_string(source_code):
            print("%(name)s (%(type)s) args: %(args)s" % func)


    prints::

        is_odd (int) args: [['int', 'x']]
        dec_to_hex (int) args: [['char', 'hchar']]
    z.opening and closing strings cannot be the samer)�exactc�(�|dj�Sr��striprs rrznested_expr.<locals>.<lambda>�����1�����rc�(�|dj�Srr�rs rrznested_expr.<locals>.<lambda>�r�rc�(�|dj�Srr�rs rrznested_expr.<locals>.<lambda>r�rc�(�|dj�Srr�rs rrznested_expr.<locals>.<lambda>
r�rzOopening and closing arguments must be strings if no content expression is givenznested z expression)�
quoted_string�
ValueErrorrnrorvrwr'r2�Combiner��
CharsNotIn�
ParserElement�DEFAULT_WHITE_CHARSr#�emptyr$r-r r��Suppress�
ZeroOrMorer%)r�r�r�r�r�r�s      r�nested_exprr��s`��V�[� �$.�-�/�$A�[�z�
�
����I�J�J����f�h�'�J�v�x�,H��[�[��f�-�F��[�[��f�-�F��6�{�a��C��K�1�$4��)�%�!�'�K�(� &���-�2S�2S� S�&'�����'�&�'=�>��$�j�j�l�Z����-�*K�*K�K�.�&�&�'=�>�?�G��)�%�!�'�K�&�v��.�/�&�v��.�/�)��)J�)J�RS�T�U���'�&�'=�>��&�!�$�V�_�,�&�v��.�/�(��)J�)J�RS�T�U���'�&�'=�>�
��a��
��)�C������V��z�*�s�*:�W�*D�E�E��QW�HX�X�
�	
��	��h�v�&��C�'�M�)B�B�X�f�EU�U�V�V���L�L�V�V�<�=��Jr�<�>c
���t|t�r|�t||��}n|j�t	t
tdz�}|r�tj�jt�}||d�zttt|td�z|z���ztddg��d�jd	��z|z}n�t j�jt�t	t"d
��z}||d�zttt|jd��ttd�|z�z���ztddg��d�jd
��z|z}t%t'd�|zd
zd��}|j)d�z�|j+�fd��|ddj-�j/dd�j1�j3��z�j)d�z�}�|_�|_t7|��|_||fS)zRInternal helper to construct opening and closing tag expressions, given a tag name)rHz_-:�tag�=�/F)�defaultr�c��|ddk(S�Nrr�rVr�s   rrz_makeTags.<locals>.<lambda>-����!����rr�)�
exclude_charsc�(�|dj�Srrirs rrz_makeTags.<locals>.<lambda>;s��q��t�z�z�|�rc��|ddk(Sr�rVr�s   rrz_makeTags.<locals>.<lambda>Ar�rz</)�adjacentz<%s>c	���|jddj�jdd�j�j	��z|j��S)N�startr`�:� )�__setitem__r��replace�titlerxr$)r�resnames �rrz_makeTags.<locals>.<lambda>JsF���!�-�-��b�g�g�g�o�o�c�3�7�=�=�?�E�E�G�H�H�!�&�&�(�
�r�endr`r�r�z</%s>)rnroru�namer!�alphas�	alphanums�dbl_quoted_stringr$r#�
remove_quotesr�r�r�r��Optr��
printablesr�r-r%r&r�r�r�rxr��SkipTo�tag_body)	�tagStr�xml�suppress_LT�suppress_GT�tagAttrName�tagAttrValue�openTag�closeTagr�s	        @r�	_makeTagsr�s1����&�(�#�����c�'�2���+�+���v�y�5�0�1�K�
�(�-�-�/�@�@��O����U�m�
��:�e�K�(�3�-�$?�,�$N�O�P�Q�
R�(�c�#��w�'��0�A�A�+��
��

�	�%�)�)�+�<�<�]�K�d��c�O
�
��
��U�m�
����#�4�4�5K�L��h�s�m�l�:�;�<����	
�(�c�#��w�'��0�A�A�+��
��

�	� �w�t�}�v�-��3�e�D�H����V�g�%�&����	
��
�
��������S�1�7�7�9�?�?�A�B�B���h�w�� �!�
��G�K��H�L��h�j�)�G���H��r�tag_strc��t|d�S)aPHelper to construct opening and closing tag expressions for HTML,
    given a tag name. Matches tags in either upper or lower case,
    attributes with namespaces and with quoted or unquoted values.

    Example::

        text = '<td>More info at the <a href="https://github.com/pyparsing/pyparsing/wiki">pyparsing</a> wiki page</td>'
        # make_html_tags returns pyparsing expressions for the opening and
        # closing tags as a 2-tuple
        a, a_end = make_html_tags("A")
        link_expr = a + SkipTo(a_end)("link_text") + a_end

        for link in link_expr.search_string(text):
            # attributes in the <A> tag (like "href" shown here) are
            # also accessible as named results
            print(link.link_text, '->', link.href)

    prints::

        pyparsing -> https://github.com/pyparsing/pyparsing/wiki
    F�r��r�s r�make_html_tagsrWs��0�W�e�$�$rc��t|d�S)z�Helper to construct opening and closing tag expressions for XML,
    given a tag name. Matches tags only in the given upper/lower case.

    Example: similar to :class:`make_html_tags`
    Trrs r�
make_xml_tagsrrs���W�d�#�#r�any_open_tag�
any_close_tagz_:zany tag�;z&(?P<entity>rcz);zcommon HTML entityc�@�tj|j�S)zRHelper parser action to replace common HTML entities with their special characters)�_htmlEntityMap�get�entityr�s   r�replace_html_entityr�s�����a�h�h�'�'rc��eZdZdZdZdZy)�OpAssoczvEnumeration of operator associativity
    - used in constructing InfixNotationOperatorSpec for :class:`infix_notation`rrLN)�__name__�
__module__�__qualname__�__doc__�LEFT�RIGHTrVrrrr�s��T�
�D�
�Err�	base_expr�op_list�lpar�rparc	�H�Gd�dt�}d|_t�}t|t�rt|�}t|t�rt|�}t|t
�rt|t
�s|t
||z|z�z}n|||z|zz}t|�D�]�\}}|dzdd\}	}
}}t|	t�rtj|	�}	tjt|	�}	|
dk(r<t|	ttf�rt|	�dk7rt!d	��|	\}
}|
�|�d
�}n|	�d
�}d|
cxkrdkst!d��t!d��|t"j$t"j&fvrt!d
��t�j)|�}tjt|�}|t"j$ur�|
dk(r|||	z�t
||	dz�z}�nU|
dk(rC|	�%|||	z|z�t
||	|zdz�z}�n)|||z�t
|d�z}�n
|
dk(�r||
z|zz|z�t
|t+|
|z|z|z�z�z}n�|t"j&ur�|
dk(r@t|	t,�st-|	�}	||	j.|z�t
|	|z�z}nz|
dk(rD|	�$|||	z|z�t
||	|zdz�z}nO|||z�t
||dz�z}n1|
dk(r,||
z|zz|z�t
||
z|z|z|z�z}|r7t|ttf�rj0|�nj1|�||zj3|�z}|}���||z}|S)a�Helper method for constructing grammars of expressions made up of
    operators working in a precedence hierarchy.  Operators may be unary
    or binary, left- or right-associative.  Parse actions can also be
    attached to operator expressions. The generated parser will also
    recognize the use of parentheses to override operator precedences
    (see example below).

    Note: if you define a deep operator list, you may see performance
    issues when using infix_notation. See
    :class:`ParserElement.enable_packrat` for a mechanism to potentially
    improve your parser performance.

    Parameters:

    - ``base_expr`` - expression representing the most basic operand to
      be used in the expression
    - ``op_list`` - list of tuples, one for each operator precedence level
      in the expression grammar; each tuple is of the form ``(op_expr,
      num_operands, right_left_assoc, (optional)parse_action)``, where:

      - ``op_expr`` is the pyparsing expression for the operator; may also
        be a string, which will be converted to a Literal; if ``num_operands``
        is 3, ``op_expr`` is a tuple of two expressions, for the two
        operators separating the 3 terms
      - ``num_operands`` is the number of terms for this operator (must be 1,
        2, or 3)
      - ``right_left_assoc`` is the indicator whether the operator is right
        or left associative, using the pyparsing-defined constants
        ``OpAssoc.RIGHT`` and ``OpAssoc.LEFT``.
      - ``parse_action`` is the parse action to be associated with
        expressions matching this operator expression (the parse action
        tuple member may be omitted); if the parse action is passed
        a tuple or list of functions, this is equivalent to calling
        ``set_parse_action(*fn)``
        (:class:`ParserElement.set_parse_action`)
    - ``lpar`` - expression for matching left-parentheses; if passed as a
      str, then will be parsed as ``Suppress(lpar)``. If lpar is passed as
      an expression (such as ``Literal('(')``), then it will be kept in
      the parsed results, and grouped with them. (default= ``Suppress('(')``)
    - ``rpar`` - expression for matching right-parentheses; if passed as a
      str, then will be parsed as ``Suppress(rpar)``. If rpar is passed as
      an expression (such as ``Literal(')')``), then it will be kept in
      the parsed results, and grouped with them. (default= ``Suppress(')')``)

    Example::

        # simple example of four-function arithmetic with ints and
        # variable names
        integer = pyparsing_common.signed_integer
        varname = pyparsing_common.identifier

        arith_expr = infix_notation(integer | varname,
            [
            ('-', 1, OpAssoc.RIGHT),
            (one_of('* /'), 2, OpAssoc.LEFT),
            (one_of('+ -'), 2, OpAssoc.LEFT),
            ])

        arith_expr.run_tests('''
            5+3*6
            (5+3)*6
            -2--11
            ''', full_dump=False)

    prints::

        5+3*6
        [[5, '+', [3, '*', 6]]]

        (5+3)*6
        [[[5, '+', 3], '*', 6]]

        (5+x)*y
        [[[5, '+', 'x'], '*', 'y']]

        -2--11
        [[['-', 2], '-', ['-', 11]]]
    c��eZdZdd�Zy)�infix_notation.<locals>._FBc�B�|jj||�|gfSr,)r�	try_parse)�self�instringr��	doActionss    r�	parseImplz%infix_notation.<locals>._FB.parseImpl�s���I�I����#�.���7�NrN�T)rrrr!rVrr�_FBr�s��	rr#zFollowedBy>r,N��rLz@if numterms=3, opExpr must be a tuple or list of two expressionsz termrz6operator must be unary (1), binary (2), or ternary (3)z2operator must indicate right or left associativity)r.)rL.)�
FollowedByrr rnr'r�r�r~ror��_literalStringClassrvrw�tuplerzr2r�rrrr%r�r�rr#�setName)rrrrr#r��lastExprr��operDef�opExpr�arity�rightLeftAssoc�pa�opExpr1�opExpr2�	term_name�thisExprr�s                  r�infix_notationr4�s���l�j��
!�C�L�
�)�C��$�����~���$�����~��
�t�X�&�:�d�H�+E��u�T�C�Z�$�%6�7�7����s�
�T� 1�2�� ��(�>�
��7�-4�w�->���,C�)���~�r��f�h�'�"�6�6�v�>�F����]�F�3���A�:��f�u�d�m�4��F��q�8H� �V��� &��G�W�"�)�G�9�E�2�I�!�(�%�(�I��E��Q���U�V�V���U�V�V��'�,�,��
�
�!>�>��Q�R�R�")�)�"4�"4�Y�"?���;�;�w��1���W�\�\�)���z���6� 1�2�U�8�f�V�n�;T�5U�U�	��!���%� #�H�v�$5��$@� A�E� �F�X�$5�v�#>�>�E�!�I�!$�H�x�$7� 8�5��&�AQ�;R� R�I��!����w�&��1�G�;�h�F���(�Y�w��/A�G�/K�h�/V�%W�W�X�Y�	��w�}�}�
,���z�!�&�#�.� ��[�F�����h� 6�7�%���@Q�:R�R�	��!���%� #�H�v�$5��$@� A�E� �F�X�$5�v�#>�>�E�!�I�!$�H�x�$7� 8�5� �8�F�#3�3�<�!�I��!����w�&��1�G�;�h�F���(�W�,�x�7�'�A�H�L�M�N�	���"�u�d�m�,�*�	�*�*�B�/��*�*�2�.��i�(�*�3�3�I�>�>����}>�~�H��C��Jrc	�|�����j�dd���fd���fd�}�fd�}�fd�}tt�jd�j	��}t�t�j
|�zjd�}t�j
|�jd�}	t�j
|�jd	�}
|r?tt|�|zt|	t|�zt|�z�z|
z�}nDtt|�t|	t|�zt|�z�zt|
�z�}|j�fd
��|j�fd��|jtt�z�|jd�S)
a�	
    (DEPRECATED - use :class:`IndentedBlock` class instead)
    Helper method for defining space-delimited indentation blocks,
    such as those used to define block statements in Python source code.

    Parameters:

    - ``blockStatementExpr`` - expression defining syntax of statement that
      is repeated within the indented block
    - ``indentStack`` - list created by caller to manage indentation stack
      (multiple ``statementWithIndentedBlock`` expressions within a single
      grammar should share a common ``indentStack``)
    - ``indent`` - boolean indicating whether block must be indented beyond
      the current level; set to ``False`` for block of left-most statements
      (default= ``True``)

    A valid block must contain at least one ``blockStatement``.

    (Note that indentedBlock uses internal parse actions which make it
    incompatible with packrat parsing.)

    Example::

        data = '''
        def A(z):
          A1
          B = 100
          G = A2
          A2
          A3
        B
        def BB(a,b,c):
          BB1
          def BBA():
            bba1
            bba2
            bba3
        C
        D
        def spam(x,y):
             def eggs(z):
                 pass
        '''


        indentStack = [1]
        stmt = Forward()

        identifier = Word(alphas, alphanums)
        funcDecl = ("def" + identifier + Group("(" + Opt(delimitedList(identifier)) + ")") + ":")
        func_body = indentedBlock(stmt, indentStack)
        funcDef = Group(funcDecl + func_body)

        rvalue = Forward()
        funcCall = Group(identifier + "(" + Opt(delimitedList(rvalue)) + ")")
        rvalue << (funcCall | identifier | Word(nums))
        assignment = Group(identifier + "=" + rvalue)
        stmt << (funcDef | assignment | identifier)

        module_body = stmt[1, ...]

        parseTree = module_body.parseString(data)
        parseTree.pprint()

    prints::

        [['def',
          'A',
          ['(', 'z', ')'],
          ':',
          [['A1'], [['B', '=', '100']], [['G', '=', 'A2']], ['A2'], ['A3']]],
         'B',
         ['def',
          'BB',
          ['(', 'a', 'b', 'c', ')'],
          ':',
          [['BB1'], [['def', 'BBA', ['(', ')'], ':', [['bba1'], ['bba2'], ['bba3']]]]]],
         'C',
         'D',
         ['def',
          'spam',
          ['(', 'x', 'y', ')'],
          ':',
          [[['def', 'eggs', ['(', 'z', ')'], ':', [['pass']]]]]]]
    Nc����d�ddy�N���rV)�
backup_stacks�indentStacks��r�reset_stackz"indentedBlock.<locals>.reset_stack�s���&�r�*��A�rc���|t|�k\ryt||�}|�dk7r"|�dkDr
t||d��t||d��y)Nr8zillegal nestingznot a peer entry)r2�colr?�rrr�curColr:s    �r�checkPeerIndentz&indentedBlock.<locals>.checkPeerIndent�sY�����A��;���Q�����[��_�$���B��'�$�Q��+<�=�=� ��A�'9�:�:�%rc�j��t||�}|�dkDr�j|�yt||d��)Nr8znot a subentry)r=�appendr?r>s    �r�checkSubIndentz%indentedBlock.<locals>.checkSubIndent�s8����Q�����K��O�#����v�&� ��A�'7�8�8rc���|t|�k\ryt||�}�r|�vs
t||d��|�dkr�j�yy)Nznot an unindentr8)r2r=r?r�r>s    �r�
checkUnindentz$indentedBlock.<locals>.checkUnindent�sQ�����A��;���Q������+� 5� ��A�'8�9�9��K��O�#��O�O��$rz	 �INDENTr`�UNINDENTc�6���r�jd�xrdSdSr7r�)r9s�rrzindentedBlock.<locals>.<lambda>�s���-�
�!�!�"�%�.�$��T�rc�����Sr,rV)rQrR�c�dr;s    �rrzindentedBlock.<locals>.<lambda>�s	���k�m�rzindented block)rBr��LineEnd�set_whitespace_chars�suppressrr#r%r�r�r&�set_fail_action�ignorer)
�blockStatementExprr:�indentr9r@rCrE�NLrF�PEER�UNDENT�smExprr;s
 ` `        @r�
indentedBlockrWYs~���l����Q��(�+�;�9��
�7�9�1�1�%�8�A�A�C�	D�B��g���0�0��@�@�
J�
J�8�
T�F��7�#�#�O�4�=�=�b�A�D�
�W�
%�
%�m�
4�
=�
=�j�
I�F�
����G��
���u�%7�8�8�3�r�7�B�C�
D��
�
�����G���u�%7�8�8�3�r�7�B�C�
D��&�k�
�
�����I�����;�<����g��	�1�2��?�?�+�,�,rz/\*(?:[^*]|\*(?!/))*z*/zC style commentz<!--[\s\S]*?-->zHTML commentz.*zrest of linez//(?:\\\n|[^\n])*z
// commentzC++ style commentz#.*zPython style comment�_builtin_exprs��allow_trailing_delim�delim�combine�min�maxrZc�$�t||||||��S)z/(DEPRECATED - use :class:`DelimitedList` class)rY)�
DelimitedList)rr[r\r]r^rZs      r�delimited_listra	s����e�W�c�3�=Q��rc��yr,rVrVrr�
delimitedListrc&���rc��yr,rVrVrrrara)s��rc��yr,rVrVrr�countedArrayrg,���rc��yr,rVrVrr�matchPreviousLiteralrj/s��rc��yr,rVrVrr�matchPreviousExprrl2���rc��yr,rVrVrr�oneOfro5s��
rc��yr,rVrVrr�dictOfrq8s��rc��yr,rVrVrr�originalTextForrs;s��rc��yr,rVrVrr�
nestedExprru>s��rc��yr,rVrVrr�makeHTMLTagsrwArhrc��yr,rVrVrr�makeXMLTagsryDs��rc��yr,rVrVrr�replaceHTMLEntityr{Grmrc��yr,rVrVrr�
infixNotationr}Jrdrr,)FTFr")�,FNN)a�
html.entities�htmlre�sysrvr`r�core�utilrrrr	r��Optionalr(r;rD�Unionryr'�boolr�r�r�r�r�r�r�r�r��Tuplerr�__annotations__r!r�r�r%rr�entities�html5�items�rstripr	r�r��common_html_entityr�Enumr�InfixNotationOperatorArgTyper�ParseAction�InfixNotationOperatorSpec�Listr4rWr��c_style_comment�html_comment�leave_whitespace�rest_of_line�dbl_slash_comment�cpp_style_comment�java_style_comment�python_style_comment�vars�valuesrnrXra�opAssoc�
anyOpenTag�anyCloseTag�commonHTMLEntity�
cStyleComment�htmlComment�
restOfLine�dblSlashComment�cppStyleComment�javaStyleComment�pythonStyleCommentr`rcrgrjrlrorqrsrurwryr{r})�k�vs00r�<module>r�s����	�
�
�����04�9I�/3�	9I�
�9I��o�o�m�,�9I��_�_�]�
+�	9I�
�9I�x���=��B!�m�!�
�!�L���	{���{�
�����$�c�)�
*�{��{��{��	{��
{��{��{�|%/��%/�}�%/��%/�R,0�2�EI�2�
�2�$(�2�>B�2��2�jA�-�A�M�A� �m� �
� �H),�(+�.2�!.��	@�!.��
@��#�}�$�%�@��#�}�$�%�@��_�_�]�
+�@��	@��
@��@�F(0��}�(�3�-�7�t%�
�3�
�%�
&�%�
�=�-�'�(�%�6$�
�3�
�%�
&�$�
�=�-�'�(�$�����,����T�!�"�+�+�I�6����m�04�}�}�/B�/B�/H�/H�/J�K�t�q�!�!�(�(�3�-��"�K���>�C�H�H�^�,D�D�t�K�L�U�U����
(�
�d�� %��3��e�M�3�$6�7��}�c�?Q�9R�R�S�S� ��"�	�$�������$�	&��
�$���	��
���$'/�s�m�&.�s�m�	n��n�
�+�
,�n���]�"�
#�n���]�"�
#�	n�
�n�b;?�b�L-�`�%� 7�8�4�?�@�I�I����$��'�(�1�1�.�A��&��U�|�,�,�.�7�7��G���.�/�8�8��F��1��	�
!�"�T�)�,=�=��
�(����P�&��$��V�}�-�-�.D�E��0��v�}�}��'�
�*�Q�
�">�A�'���]�#��(+�� $� $��"'��
��]�"�
#����m�#�$����
����	�	�

����	������"��
�
���%���
���
�
�#��#��%��)���-� ��!���-� ��!���-� ��!���(�)��*���%�&��'���&������'������#�$��%���+������.�!��"���-� ��!���%�&��'���.�!��"���QL��@'s�?P6�
P<�P<

Zerion Mini Shell 1.0