HOME


Mini Shell 1.0
DIR: /lib/python3/dist-packages/jinja2/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/jinja2/__pycache__/parser.cpython-312.pyc
�

��+b����>�UdZddlZddlZddlmZddlmZddlmZddlm	Z	ddlm
Z
ejr
ddlZ
dd	lmZej d
ej"ej$�Zej dej(ej*�Zegd��Zegd
��Zej4ej6ej8ej:ej<ej>d�Z ejBe"ejFejHfe%d<Gd�d�Z&y)z8Parse tokens from the lexer into nodes for the compiler.�N�)�nodes)�TemplateAssertionError)�TemplateSyntaxError)�describe_token)�describe_token_expr)�Environment�_ImportInclude�
_MacroCall)�for�if�block�extends�print�macro�include�from�import�set�with�
autoescape)�eq�ne�lt�lteq�gt�gteq)�add�sub�mul�div�floordiv�mod�_math_nodesc�P�eZdZdZ			dSdddedejedejedejed	dfd
�Zdefdedeje	d
ejed	dfd�Zdejedejejedfdeje	d	dfd�Z	dTdedeje	d	dfd�Z		dUdejejedfdeje	d	dfd�Z	dTdejejedfd	efd�ZdTdeje	d	ej(fd�Zd	ej,ej.ejej.ffd�Z	dVdejedfded	ejej.fd�Zd	ej,ej4ej6ffd�Zd	ej:fd�Zd	ej>fd�Z d	ejBfd�Z"d	ejFfd �Z$d	ejJfd!�Z&d	ejNfd"�Z(d#e)d$ed	e)fd%�Z*d	ejVfd&�Z,d	ejZfd'�Z.d	ej^fd(�Z0d#e1d	dfd)�Z2d	ejffd*�Z4d	ejjfd+�Z6d	ejnfd,�Z8d	ejrfd-�Z:e;jx	dWd.ed/d0d	ejzfd1��Z>e;jx				dXd.ed/edejejedfd2ed	ej,ej~ejzejff
d3��Z>				dXd.ed/edejejedfd2ed	ej,ej~ejzejff
d4�Z>dYd5ed	ej�fd6�ZAd	ej�fd7�ZBd	ej�fd8�ZCd	ej�fd9�ZDd	ej�fd:�ZEd	ej�fd;�ZFd	ej�fd<�ZGd	ej�fd=�ZHd	ej�fd>�ZId	ej�fd?�ZJdYd@ed	ej�fdA�ZKd	ej�fdB�ZL				dZdCed5edejejedfdDed	ej,ejej�ff
dE�ZMd	ejfdF�ZNd	ej�fdG�ZPd#ej�d	ej�fdH�ZQd#ej�d	ej�fdI�ZRd#ej�d	ej,ej�ej�ffdJ�ZUd	ej�fdK�ZVd	ejfdL�ZWd#ej�d	ej�fdM�ZY	dVd#ejej�dNed	ejej�fdO�ZZd#ej�d	ej�fdP�Z[	dTdejejedfd	ejej.fdQ�Z\d	ej�fdR�Z^y)[�Parserz�This is the central parsing class Jinja uses.  It's passed to
    extensions and can be used to parse expressions or statements.
    N�environmentr	�source�name�filename�state�returnc�$�||_|j||||�|_||_||_d|_i|_|j�D],}|jD]}|j|j|<��.d|_
g|_g|_y)NFr)
r'�	_tokenize�streamr)r*�closed�
extensions�iter_extensions�tags�parse�_last_identifier�
_tag_stack�_end_token_stack)�selfr'r(r)r*r+�	extension�tags        �//usr/lib/python3/dist-packages/jinja2/parser.py�__init__zParser.__init__3s���'���!�+�+�F�D�(�E�J�����	� ��
����
�	
��%�4�4�6�	7�I� �~�~�
7��'0�������$�
7�	7�!"���')���;=����msg�lineno�exczte.NoReturnc��|� |jjj}||||j|j��)z�Convenience method that raises `exc` with the message, passed
        line number or last line number as well as the current name and
        filename.
        )r/�currentr?r)r*)r8r>r?r@s    r;�failzParser.failJs7���>��[�[�(�(�/�/�F��#�v�t�y�y�$�-�-�8�8r=�end_token_stack.c
���t�}|D]!}|jtt|���#|r1dj	tt
tt|d���}nd}|�dg}nd|�d�g}|r1|�||vr|j
d|�d��n|j
d|�d��|jr"|j
d|jd�d��|jd	j	|�|�y)
Nz or ���zUnexpected end of template.zEncountered unknown tag �.z\You probably made a nesting mistake. Jinja is expecting this tag, but currently looking for z*Jinja was looking for the following tags: z/The innermost block that needs to be closed is � )	r�update�mapr�join�repr�appendr6rC)r8r)rDr?�expected�exprs�currently_looking�messages        r;�_fail_ut_eofzParser._fail_ut_eofXs�� #�u��$�	=�E��O�O�C� 3�U�;�<�	=��17����D�#�1�?�2�3F�G�H�2��!%���<�4�5�G�1�$���;�<�G����D�H�$4����2�2C�1D�A�G��
���@�AR�@S�ST�U���?�?��N�N���O�O�B�'�*�!�-�
�
	
�	�	�#�(�(�7�#�V�,r=c�>�|j||j|�y)z�Called if the parser encounters an unknown tag.  Tries to fail
        with a human readable error message that could help to identify
        the problem.
        N)rRr7)r8r)r?s   r;�fail_unknown_tagzParser.fail_unknown_tag�s��	
���$�� 5� 5�v�>r=�
end_tokensc�z�t|j�}|�|j|�|jd||�y)z9Like fail_unknown_tag but for end of template situations.N)�listr7rMrR)r8rUr?�stacks    r;�fail_eofzParser.fail_eof�s8���T�*�*�+���!��L�L��$����$��v�.r=�extra_end_rulesc��|jjjdvry|�%|jjj|�Sy)zAre we at the end of a tuple?)�variable_end�	block_end�rparenTF)r/rB�type�test_any)r8rZs  r;�is_tuple_endzParser.is_tuple_end�sD���;�;���#�#�'N�N��
�
(��;�;�&�&�/�/��@�@�r=c���|xjdz
c_tjtj�}tj
j
|d|j��|��|S)zDReturn a new free identifier as :class:`~jinja2.nodes.InternalName`.r�fi�r?)r5�object�__new__r�InternalName�Noder<)r8r?�rvs   r;�free_identifierzParser.free_identifier�sS������"��
�^�^�E�.�.�
/��
�
�
���B�"�T�%:�%:�$;� <�V��L��	r=c�&�|jj}|jdk7r|jd|j�|j
j
|j�d}	|jtvrQt|d|jjj���}|�|r|j
j�SS|jdk(r-|j�|r|j
j�SS|jdk(r-|j�|r|j
j�SS|jj|j�}|�%||�|r|j
j�SS|j
j�d}|j|j|j�|r|j
j�yy#|r|j
j�wwxYw)	zParse a single statement.r)ztag name expectedT�parse_�call�filterNF)r/rBr_rCr?r6rM�value�_statement_keywords�getattr�pop�parse_call_block�parse_filter_blockr1�getrT)r8�token�pop_tag�f�exts     r;�parse_statementzParser.parse_statement�s������#�#���:�:����I�I�)�5�<�<�8������u�{�{�+���	&��{�{�1�1��D�F�4�;�;�+>�+>�+D�+D�*E�"F�G���s� ����#�#�%���{�{�f�$��,�,�.�����#�#�%���{�{�h�&��.�.�0�����#�#�%���/�/�%�%�e�k�k�2�C����4�y�����#�#�%��	
�O�O���!��G��!�!�%�+�+�u�|�|�<�����#�#�%���w����#�#�%��s&�*AG1�
G1�	G1�.G1�AG1�1H�drop_needlec�*�|jjd�|jjd�|j|�}|jjj
dk(r|j
|�|rt|j�|S)aRParse multiple statements into a list until one of the end tokens
        is reached.  This is used to parse the body of statements as it also
        parses template data if appropriate.  The parser checks first if the
        current token is a colon and skips it if there is one.  Then it checks
        for the block end and parses until if one of the `end_tokens` is
        reached.  Per default the active token in the stream at the end of
        the call is the matched end token.  If this is not wanted `drop_needle`
        can be set to `True` and the end token is removed.
        �colonr]�eof)r/�skip_if�expect�subparserBr_rY�next)r8rUr{�results    r;�parse_statementszParser.parse_statements�sr��	
�����G�$�	
�����;�'����z�*���;�;���#�#�u�,��M�M�*�%��������
r=c�d�t|j�j}|jd��}|jj	d�r(|j�}t
j|||��S|jd�}|jdd��}t
j||||��S)zParse an assign statement.T)�with_namespace�assignrdN)zname:endset�r{)r�r/r?�parse_assign_targetr�parse_tupler�Assign�parse_filterr��AssignBlock)r8r?�target�expr�filter_node�bodys      r;�	parse_setzParser.parse_set�s����d�k�k�"�)�)���)�)��)�>���;�;���x�(��#�#�%�D��<�<���V�<�<��'�'��-���$�$�%5�4�$�H��� � ���d�6�J�Jr=c	�&�|jjd�j}|jd��}|jjd�|j	dd��}d}|jjd	�r|j
�}|jjd
�}|jd�}t|j�jdk(rg}n|jd
d��}tj|||||||��S)zParse a for loop.zname:for)�name:in)rZr�F)�name:recursive)�
with_condexprrZN�name:ifr�)�name:endfor�	name:else�endfor)r�Tr�rd)r/r�r?r�r�r�parse_expressionr�r�ror�For)r8r?r��iter�test�	recursiver��else_s        r;�	parse_forzParser.parse_for�s������#�#�J�/�6�6���)�)�,�)�G�������9�%�����1D� �
�����;�;���y�)��(�(�*�D��K�K�'�'�(8�9�	��$�$�%A�B�������"�"�h�.��E��)�)�*:��)�M�E��y�y���t�U�D�)�F�S�Sr=c�4�tj|jjd�j��x}}	|jd��|_|jd�|_g|_	g|_
t|j�}|j
d�rPtj|jjj��}|jj|���|j
d�r|jd	d�
�|_
	|S)zParse an if construct.r�rdTF�r�)�	name:elifr��
name:endifr�r�)r�r�)r�Ifr/r�r?r�r�r�r��elif_r�r�rBrM)r8�noder�rvs    r;�parse_ifzParser.parse_if�s���������(:�(:�9�(E�(L�(L�M�M��v���(�(�u�(�=�D�I��-�-�.V�W�D�I��D�J��D�J�����%�E��z�z�+�&��x�x�t�{�{�':�':�'A�'A�B�����#�#�D�)�����K�(�#�4�4�_�RV�4�W�����
r=c�`�tjt|j�j��}g}g}|jj
jdk7r�|r|jjd�|j�}|jd�|j|�|jjd�|j|j��|jj
jdk7r��||_||_
|jdd��|_|S)	Nrdr]�comma�paramr�)zname:endwithTr�)r�Withr�r/r?rBr_r�r��set_ctxrMr��targets�valuesr�r�)r8r�r�r�r�s     r;�
parse_withzParser.parse_withs����z�z��d�k�k�!2�!9�!9�:��&(��%'���k�k�!�!�&�&�+�5�����"�"�7�+��-�-�/�F��N�N�7�#��N�N�6�"��K�K���x�(��M�M�$�/�/�1�2��k�k�!�!�&�&�+�5��������)�)�*;��)�N��	��r=c��tjt|j�j��}tj
d|j
��g|_|jdd��|_	tj|g�S)Nrdr)zname:endautoescapeTr�)r�ScopedEvalContextModifierr�r/r?�Keywordr��optionsr�r��Scope�r8r�s  r;�parse_autoescapezParser.parse_autoescape sh���.�.�d�4�;�;�6G�6N�6N�O���
�
�l�D�4I�4I�4K�L�M����)�)�*A�t�)�T��	��{�{�D�6�"�"r=c��tjt|j�j��}|jjd�j|_|jjd�|_	|jjd�|_
|jjjdk(r|jd�|jdd�	�|_|jr-t!d
�|jD��s|jd�|jjd|jz�|S)
Nrdr)zname:scopedz
name:requiredrzpBlock names in Jinja have to be valid Python identifiers and may not contain hyphens, use an underscore instead.)z
name:endblockTr�c3�K�|]K}|jD]:}t|tj�xr|jj	����<�My�w�N)r�
isinstance�TemplateData�data�isspace)�.0r��childs   r;�	<genexpr>z%Parser.parse_block.<locals>.<genexpr>:sS����%
�����%
��
�u�e�0�0�1�J�e�j�j�6H�6H�6J�J�%
�J�%
�s�AAz7Required blocks can only contain comments or whitespacezname:)r�Blockr�r/r?r�ror)r�scoped�requiredrBr_rCr�r��allr�s  r;�parse_blockzParser.parse_block&s����{�{�$�t�{�{�"3�":�":�;���K�K�&�&�v�.�4�4��	��k�k�)�)�-�8������+�+�O�<��
�
�;�;���#�#�u�,��I�I�?�
�
�)�)�*<�$�)�O��	�
�=�=��%
��	�	�%
�"
�

�I�I�O�P������G�d�i�i�/�0��r=c��tjt|j�j��}|j�|_|S�Nrd)r�Extendsr�r/r?r��templater�s  r;�
parse_extendszParser.parse_extendsDs4���}�}�D����$5�$<�$<�=���-�-�/��
��r=r��defaultc�8�|jjjdd�rl|jj�j	d�rCt|j�jdk(|_|jj�|S||_|S)Nz	name:withzname:without�name:contextr)	r/rBr`�lookr�r�ro�with_context�skip)r8r�r�s   r;�parse_import_contextzParser.parse_import_contextIs~���;�;���'�'���
��k�k��� �%�%�n�5� $�T�[�[� 1� 7� 7�6� A�D���K�K������!(�D���r=c��tjt|j�j��}|j�|_|jjjd�rL|jj�jd�r#d|_
|jjd�nd|_
|j|d�S)Nrdzname:ignorezname:missingT�F)
r�Includer�r/r?r�r�rBr�r��ignore_missingr�r�r�s  r;�
parse_includezParser.parse_includeUs����}�}�D����$5�$<�$<�=���-�-�/��
��;�;���#�#�M�2�t�{�{�7G�7G�7I�7N�7N��8
�#'�D���K�K���Q��"'�D���(�(��t�4�4r=c�.�tjt|j�j��}|j�|_|jjd�|jd��j|_
|j|d�S)Nrd�name:asT��	name_onlyF)r�Importr�r/r?r�r�r�r�r)r�r�r�s  r;�parse_importzParser.parse_importaso���|�|�4����#4�#;�#;�<���-�-�/��
������9�%��.�.��.�>�C�C����(�(��u�5�5r=c����tjt�j�j����j��_�jjd�g�_dtf��fd�}	�jr�jjd��jjjdk(�r|�r�n�jd��}|jjd	�r"�jd
|jt ���jj#d�rD�jd��}�jj%|j|jf�n%�jj%|j�|�s#�jjjdk7rn�jjd���ot'�d
�sd�_�S)Nrdzname:importr,c� ���jjjdvrk�jj�j	d�rBt�j�jdk(�_�jj�yy)N>r�withoutr�rTF)r/rBror�r�r�r�r�)r�r8s��r;�
parse_contextz(Parser.parse_from.<locals>.parse_contextnso����{�{�"�"�(�(�-���+�+�"�"�$�)�)�.�9�$(����$5�$;�$;�v�$E��!���� � �"��r=Tr�r)r��_z4names starting with an underline can not be imported)r@r�r�F)r�
FromImportr�r/r?r�r�r��names�boolrBr_r�r)�
startswithrCrrrM�hasattrr�)r8r�r��aliasr�s`   @r;�
parse_fromzParser.parse_fromhs�������t�D�K�K�'8�'?�'?�@���-�-�/��
������=�)���
�	�t�	���z�z����"�"�7�+��{�{�"�"�'�'�6�1� �?���1�1�D�1�A���;�;�)�)�#�.��I�I�N��
�
�2���
�;�;�&�&�y�1� �4�4�t�4�D�E��J�J�%�%�v�{�{�E�J�J�&?�@��J�J�%�%�f�k�k�2� �?�d�k�k�&9�&9�&>�&>�'�&I�����"�"�6�*�+�,�t�^�,� %�D���r=c�`�gx}|_gx}|_|jjd�|jjj
dk7r�|r|jjd�|j
d��}|jd�|jjd�r |j|j��n|r|jd�|j|�|jjj
dk7r��|jjd�y)	N�lparenr^r�Tr�r�r�z-non-default argument follows default argument)�args�defaultsr/r�rBr_r�r�rrMr�rC)r8r�r�r��args     r;�parse_signaturezParser.parse_signature�s������t�y�#%�%��4�=������8�$��k�k�!�!�&�&�(�2�����"�"�7�+��*�*�T�*�:�C��K�K�� ��{�{�"�"�8�,����� 5� 5� 7�8���	�	�I�J��K�K����k�k�!�!�&�&�(�2�	
�����8�$r=c��tjt|j�j��}|jj
jdk(r|j|�ng|_g|_	|j�}t|tj�s|jd|j�||_|jdd��|_|S)Nrdr�z
expected call)zname:endcallTr�)r�	CallBlockr�r/r?rBr_r�r�r�r�r��CallrCrmr�r�)r8r��	call_nodes   r;rszParser.parse_call_block�s������d�4�;�;�&7�&>�&>�?���;�;���#�#�x�/�� � ��&��D�I��D�M��)�)�+�	��)�U�Z�Z�0��I�I�o�t�{�{�3���	��)�)�*;��)�N��	��r=c���tjt|j�j��}|jdd��|_|jdd��|_|S)NrdT)�start_inline)zname:endfilterr�)	r�FilterBlockr�r/r?r�rnr�r�r�s  r;rtzParser.parse_filter_block�sU��� � ��T�[�[�(9�(@�(@�A���'�'��4�'�@����)�)�*=�4�)�P��	��r=c��tjt|j�j��}|jd��j|_|j|�|jdd��|_	|S)NrdTr�)z
name:endmacror�)
r�Macror�r/r?r�r)r�r�r�r�s  r;�parse_macrozParser.parse_macro�se���{�{�$�t�{�{�"3�":�":�;���,�,�t�,�<�A�A��	����T�"��)�)�*<�$�)�O��	��r=c��tjt|j�j��}g|_|jj
jdk7rt|jr|jjd�|jj|j��|jj
jdk7r�t|S)Nrdr]r�)
r�Outputr�r/r?rBr_r�rMr�r�s  r;�parse_printzParser.parse_print�s����|�|�4����#4�#;�#;�<����
��k�k�!�!�&�&�+�5��z�z����"�"�7�+��J�J���d�3�3�5�6��k�k�!�!�&�&�+�5��r=�
with_tupler�zte.Literal[True]c��yr��)r8r�r�s   r;r�zParser.parse_assign_target�s��	r=r�c��yr�r)r8r�r�rZr�s     r;r�zParser.parse_assign_target�s��	r=c��|r�|jj�jdk(r�|jjd�}t	|j�|jjd�}tj|j|j|j��}n�|rH|jjd�}tj|jd|j��}n7|r|jd|��}n|j�}|jd�|j�s@|jdt|�jj!���|j�|S)aParse an assignment target.  As Jinja allows assignments to
        tuples, this function can parse all allowed assignment targets.  Per
        default assignments to tuples are parsed, that can be disable however
        by setting `with_tuple` to `False`.  If only assignments to names are
        wanted `name_only` can be set to `True`.  The `extra_end_rules`
        parameter is forwarded to the tuple parsing function.  If
        `with_namespace` is enabled, a namespace assignment may be parsed.
        �dotr)rd�storeT)�
simplifiedrZzcan't assign to )r/r�r_r�r�r�NSRefror?�Namer��
parse_primaryr��
can_assignrC�__name__�lower)r8r�r�rZr�rv�attrr�s        r;r�zParser.parse_assign_target�s ��"�d�k�k�.�.�0�5�5��>��K�K�&�&�v�.�E�������;�;�%�%�f�-�D��[�[����d�j�j����N�F�
��K�K�&�&�v�.�E��Z�Z����W�U�\�\�J�F���)�)�#�_�*����+�+�-���N�N�7�#�� � �"��I�I�"�4��<�#8�#8�#>�#>�#@�"C�D�f�m�m�
��
r=r�c�F�|r|j�S|j�S)z�Parse an expression.  Per default all expressions are parsed, if
        the optional `with_condexpr` parameter is set to `False` conditional
        expressions are not parsed.
        )�parse_condexpr�parse_or)r8r�s  r;r�zParser.parse_expressions"��
��&�&�(�(��}�}��r=c���|jjj}|j�}|jj	d�r�|j�}|jj	d�r|j�}nd}t
j||||��}|jjj}|jj	d�r��|S)Nr�r�rd)r/rBr?rrrr�CondExpr)r8r?�expr1�expr2�expr3s     r;rzParser.parse_condexpr
s������$�$�+�+���
�
����k�k�!�!�)�,��M�M�O�E��{�{�"�"�;�/��+�+�-�����N�N�5�%��v�F�E��[�[�(�(�/�/�F��k�k�!�!�)�,��r=c�d�|jjj}|j�}|jj	d�rd|j�}tj|||��}|jjj}|jj	d�r�d|S)N�name:orrd)r/rBr?�	parse_andrr�Or�r8r?�left�rights    r;rzParser.parse_ors������$�$�+�+���~�~����k�k�!�!�)�,��N�N�$�E��8�8�D�%��7�D��[�[�(�(�/�/�F��k�k�!�!�)�,��r=c�d�|jjj}|j�}|jj	d�rd|j�}tj|||��}|jjj}|jj	d�r�d|S)N�name:andrd)r/rBr?�	parse_notrr�Andrs    r;rzParser.parse_and"s������$�$�+�+���~�~����k�k�!�!�*�-��N�N�$�E��9�9�T�5��8�D��[�[�(�(�/�/�F��k�k�!�!�*�-��r=c���|jjjd�rDt|j�j}tj|j�|��S|j�S)N�name:notrd)	r/rBr�r�r?r�Notr�
parse_compare)r8r?s  r;rzParser.parse_not+sU���;�;���#�#�J�/��$�+�+�&�-�-�F��9�9�T�^�^�-�f�=�=��!�!�#�#r=c��|jjj}|j�}g}	|jjj}|t
vrIt
|j�|jtj||j���n�|jjd�r4|jtjd|j���n�|jjjd�rx|jj�jd�rO|jjd�|jtjd|j���nn"|jjj}���|s|Stj|||��S)Nr��inr!r��notinrd)r/rBr?�parse_math1r_�_compare_operatorsr�rMr�Operandrr�r�r��Compare)r8r?r��ops�
token_types     r;r#zParser.parse_compare1sL�����$�$�+�+�����!��������,�,�1�1�J��/�/��T�[�[�!��
�
�5�=�=��T�5E�5E�5G�H�I����$�$�Y�/��
�
�5�=�=��t�/?�/?�/A�B�C����$�$�)�)�*�5�$�+�+�:J�:J�:L�:Q�:Q��;���� � ��#��
�
�5�=�=��$�2B�2B�2D�E�F���[�[�(�(�/�/�F����K��}�}�T�3�v�6�6r=c���|jjj}|j�}|jjjdvr�t
|jjj}t
|j�|j�}||||��}|jjj}|jjjdvr��|S)N)rrrd)r/rBr?�parse_concatr_r$r��r8r?r�clsrs     r;r'zParser.parse_math1Hs������$�$�+�+��� � �"���k�k�!�!�&�&�.�8��d�k�k�1�1�6�6�7�C�������%�%�'�E��t�U�6�2�D��[�[�(�(�/�/�F��k�k�!�!�&�&�.�8��r=c��|jjj}|j�g}|jjjdk(rXt|j�|j
|j��|jjjdk(r�Xt|�dk(r|dStj||��S)N�tilderrrd)
r/rBr?�parse_math2r_r�rM�lenr�Concat)r8r?r�s   r;r.zParser.parse_concatSs������$�$�+�+��� � �"�#���k�k�!�!�&�&�'�1�������K�K��(�(�*�+��k�k�!�!�&�&�'�1��t�9��>���7�N��|�|�D��0�0r=c���|jjj}|j�}|jjjdvr�t
|jjj}t
|j�|j�}||||��}|jjj}|jjjdvr��|S)N)r r!r"r#rd)r/rBr?�	parse_powr_r$r�r/s     r;r3zParser.parse_math2]s������$�$�+�+���~�~����k�k�!�!�&�&�*K�K��d�k�k�1�1�6�6�7�C�������N�N�$�E��t�U�6�2�D��[�[�(�(�/�/�F��k�k�!�!�&�&�*K�K��r=c��|jjj}|j�}|jjjdk(r�t|j�|j�}t
j|||��}|jjj}|jjjdk(r��|S)N�powrd)r/rBr?�parse_unaryr_r�r�Powrs    r;r7zParser.parse_powhs������$�$�+�+�����!���k�k�!�!�&�&�%�/�������$�$�&�E��9�9�T�5��8�D��[�[�(�(�/�/�F�	�k�k�!�!�&�&�%�/�
�r=�with_filterc���|jjj}|jjj}|dk(r<t	|j�tj|jd�|��}nQ|dk(r<t	|j�tj|jd�|��}n|j�}|j|�}|r|j|�}|S)NrFrdr)r/rBr_r?r�r�Negr:�Posr�
parse_postfix�parse_filter_expr)r8r<r,r?r�s     r;r:zParser.parse_unaryrs����[�[�(�(�-�-�
����$�$�+�+�����������9�9�T�-�-�e�4�V�D�D�
�5�
 �������9�9�T�-�-�e�4�V�D�D��%�%�'�D��!�!�$�'����)�)�$�/�D��r=c��|jj}|jdk(r�|jdvr.t	j
|jdv|j��}n\|jdvr"t	j
d|j��}n,t	j|jd|j��}t|j�|S|jdk(r�t|j�|jg}|j}|jjjdk(rh|j|jjj�t|j�|jjjdk(r�ht	j
dj|�|��}|S|jd	vrBt|j�t	j
|j|j��}|S|jd
k(rDt|j�|jd��}|jjd
�|S|jdk(r|j�}|S|jdk(r|j�}|S|jdt!|���|j�S)Nr))�true�false�True�False)rCrErd)�none�None�load�string�)�integer�floatr�T)�explicit_parenthesesr^�lbracket�lbracezunexpected )r/rBr_ror�Constr?rr�rMrKr�r��
parse_list�
parse_dictrCr)r8rvr��bufr?s     r;rzParser.parse_primary�s'�����#�#���:�:����{�{�@�@��{�{�5�;�;�2B�#B�5�<�<�X����� 0�0��{�{�4����=���z�z�%�+�+�v�e�l�l�K�������,��+�Z�Z�8�
#�������;�;�-�C��\�\�F��+�+�%�%�*�*�h�6��
�
�4�;�;�.�.�4�4�5��T�[�[�!��+�+�%�%�*�*�h�6��;�;�r�w�w�s�|�F�;�D����Z�Z�/�
/�������;�;�u�{�{�5�<�<�@�D����Z�Z�8�
#�������#�#��#�>�D��K�K���x�(���
�Z�Z�:�
%��?�?�$�D�
��	�Z�Z�8�
#��?�?�$�D���
�I�I��N�5�$9�#<�=�u�|�|�L��r=rrNc�x���jjj}|r
�j}n%|r
�j}ndt
jf�fd�}g}d}	|r�jjd��j|�rn^|j|���jjjdk(rd}nn!�jjj}��|s:|r|dS|s1�jdt�jj����tj|d|�	�S)
a�Works like `parse_expression` but if multiple expressions are
        delimited by a comma a :class:`~jinja2.nodes.Tuple` node is created.
        This method could also return a regular expression instead of a tuple
        if no commas where found.

        The default parsing mode is a full tuple.  If `simplified` is `True`
        only names and literals are parsed.  The `no_condexpr` parameter is
        forwarded to :meth:`parse_expression`.

        Because tuples do not require delimiters and may end in a bogus comma
        an extra hint is needed that marks the end of a tuple.  For example
        for loops support tuples between `for` and `in`.  In that case the
        `extra_end_rules` is set to ``['name:in']``.

        `explicit_parentheses` is true if the parsing was triggered by an
        expression in parentheses.  This is used to figure out if an empty
        tuple is a valid expression or not.
        r,c�(���jd��S)NFr�)r�)r8s�r;r4z!Parser.parse_tuple.<locals>.parse�s����,�,�5�,�A�Ar=FTr�rzExpected an expression, got rIrd)r/rBr?rr�r�Exprr�rarMr_rCr�Tuple)	r8rr�rZrNr?r4r��is_tuples	`        r;r�zParser.parse_tuple�s���2���$�$�+�+����&�&�E�
��)�)�E�
B�5�:�:�
B�$&���������"�"�7�+�� � ��1���K�K��� ��{�{�"�"�'�'�7�2�����[�[�(�(�/�/�F�����A�w��(��	�	��*�4�;�;�+>�+>�?�B�D��
�{�{�4���7�7r=c��|jjd�}g}|jjjdk7r�|r|jjd�|jjjdk(rnC|j	|j��|jjjdk7r��|jjd�t
j||j��S)NrO�rbracketr�rd)	r/r�rBr_rMr�r�Listr?)r8rv�itemss   r;rRzParser.parse_list�s������"�"�:�.��$&���k�k�!�!�&�&�*�4�����"�"�7�+��{�{�"�"�'�'�:�5���L�L��.�.�0�1��k�k�!�!�&�&�*�4�	
�����:�&��z�z�%����5�5r=c��|jjd�}g}|jjjdk7r�|r|jjd�|jjjdk(rn�|j	�}|jjd�|j	�}|jt
j|||j���|jjjdk7r��|jjd�t
j||j��S)NrP�rbracer�r}rd)
r/r�rBr_r�rMr�Pairr?�Dict)r8rvr]�keyros     r;rSzParser.parse_dict�s������"�"�8�,��$&���k�k�!�!�&�&�(�2�����"�"�7�+��{�{�"�"�'�'�8�3���'�'�)�C��K�K���w�'��)�)�+�E��L�L����C��s�z�z�B�C��k�k�!�!�&�&�(�2�	
�����8�$��z�z�%����5�5r=c��	|jjj}|dk(s|dk(r|j|�}n|dk(r|j	|�}n	|S�W)NrrOr�)r/rBr_�parse_subscript�
parse_call�r8r�r,s   r;r@zParser.parse_postfixs^������,�,�1�1�J��U�"�j�J�&>��+�+�D�1���x�'����t�,�����r=c��	|jjj}|dk(r|j|�}nT|dk(r5|jjjdk(r|j|�}n|dk(r|j
|�}n	|S��)N�piper)�isr�)r/rBr_r�ro�
parse_testrerfs   r;rAzParser.parse_filter_exprs�������,�,�1�1�J��V�#��(�(��.���v�%�$�+�+�*=�*=�*C�*C�t�*K����t�,���x�'����t�,�����r=c�T�t|j�}|jdk(r�|jj}t|j�|jdk(r-t	j
||jd|j��S|jdk7r|jd|j�t	j|j|j��}t	j||d|j��S|jdk(r�g}|jjjdk7r`|r|jjd	�|j|j��|jjjdk7r�`|jjd�t|�d
k(r|d}n"t	j|d|j��}t	j||d|j��S|jd|j�y)
Nrr)rIrdrLzexpected name or numberrOr[r�rrzexpected subscript expression)r�r/r_rBr�Getattrror?rCrQ�Getitemr�rM�parse_subscribedr4rX)r8r�rv�
attr_tokenr�r�s      r;rdzParser.parse_subscripts����T�[�[�!���:�:������,�,�J���������&�(��}�}��*�*�*�F�5�<�<������I�-��	�	�3�Z�5F�5F�G��+�+�j�.�.�z�7H�7H�I�C��=�=��s�F�5�<�<�H�H��:�:��#�')�D��+�+�%�%�*�*�j�8���K�K�&�&�w�/����D�1�1�3�4��+�+�%�%�*�*�j�8�
�K�K���z�*��4�y�A�~��1�g���k�k�$��u�|�|�D���=�=��s�F�5�<�<�H�H��	�	�1�5�<�<�@r=c���|jjj}|jjjdk(rt	|j�dg}nM|j�}|jjjdk7r|St	|j�|g}|jjjdk(r|j
d�nS|jjjdvr |j
|j��n|j
d�|jjjdk(rit	|j�|jjjdvr |j
|j��n#|j
d�n|j
d�tj|d|i�S)Nr})r[r�r?)	r/rBr?r_r�r�rMr�Slice)r8r?r�r�s    r;rnzParser.parse_subscribed>s^�����$�$�+�+���;�;���#�#�w�.�������6�D��(�(�*�D��{�{�"�"�'�'�7�2���������6�D��;�;���#�#�w�.��K�K���
�[�[�
 �
 �
%�
%�-B�
B��K�K��-�-�/�0��K�K����;�;���#�#�w�.�������{�{�"�"�'�'�/D�D����D�1�1�3�4����D�!��K�K����{�{�4�0�&�0�0r=c�0��	��jjd��	g}g}d}d}d}dtddf��	fd�}�jjjdk7�r|r@�jjd��jjjdk(r�nډjjjdk(r7||duxr|du�t�j��j
�}�nY�jjjd	k(r1||du�t�j��j
�}�n�jjjd
k(r��jj�jdk(r�||du��jjj}�jjd��j
�}|jtj|||j�
��n4||duxr	|duxr|�|j�j
��d}�jjjdk7r���jjd�||||fS)Nr�Fr�r,c�D��|s�jd�j�yy)Nz+invalid syntax for function call expression)rCr?)r�r8rvs ��r;�ensurez&Parser.parse_call_args.<locals>.ensurefs�����	�	�G����V�r=r^r�r r9r)r�r�rdT)r/r�r�rBr_r�r�r�ror�rMrr�r?)
r8r��kwargs�dyn_args�
dyn_kwargs�
require_commartrbrorvs
`        @r;�parse_call_argszParser.parse_call_args^s)������"�"�8�,���������
��
�	W��	W�$�	W��k�k�!�!�&�&�(�2�����"�"�7�+��;�;�&�&�+�+�x�7���{�{�"�"�'�'�5�0��x�4�'�>�J�$�,>�?��T�[�[�!��0�0�2�����$�$�)�)�U�2��z�T�)�*��T�[�[�!�!�2�2�4�
��K�K�'�'�,�,��6����(�(�*�/�/�8�;��:��-�.��+�+�-�-�3�3�C��K�K�$�$�Q�'� �1�1�3�E��M�M�%�-�-��U�5�<�<�"P�Q��8�t�+�Q�
�d�0B�Q�6�z�R��K�K�� 5� 5� 7�8� �M�A�k�k�!�!�&�&�(�2�D	
�����8�$��V�X�z�1�1r=c��|jj}|j�\}}}}tj||||||j
��Sr�)r/rBryrr�r?)r8r�rvr�rurvrws       r;rezParser.parse_call�sG�����#�#��-1�-A�-A�-C�*��f�h�
��z�z�$��f�h�
�5�<�<�X�Xr=r�c	��|jjjdk(s|�rW|st|j�|jj	d�}|j
}|jjjdk(rdt|j�|d|jj	d�j
zz
}|jjjdk(r�d|jjjdk(r|j
�\}}}}ng}g}dx}}tj|||||||j��}d}|jjjdk(r��S|r��W|S)Nrhr)rrGr�rdF)
r/rBr_r�r�roryr�Filterr?)	r8r�r�rvr)r�rurvrws	         r;r�zParser.parse_filter�s<���k�k�!�!�&�&�&�0�L���T�[�[�!��K�K�&�&�v�.�E��;�;�D��+�+�%�%�*�*�e�3��T�[�[�!���d�k�k�0�0��8�>�>�>�>���+�+�%�%�*�*�e�3��{�{�"�"�'�'�8�3�59�5I�5I�5K�2��f�h�
�����(,�,��:��<�<��d�D�&�(�J�u�|�|��D�!�L�#�k�k�!�!�&�&�&�0�L�$�r=c	�b�t|j�}|jjjd�rt|j�d}nd}|jj	d�j
}|jjjdk(rdt|j�|d|jj	d�j
zz
}|jjjdk(r�ddx}}g}|jjjdk(r|j�\}}}}n�|jjjdvr�|jjjd	d
d�s[|jjjd�r|jd
�|j�}	|j|	�}	|	g}ng}tj|||||||j��}|r!tj||j��}|S)Nr!TFr)rrGr�>r)rMrPr�rJrLrOr�rrzname:isz'You cannot chain multiple tests with isrd)r�r/rBr�r�ror_ryr`rCrr@r�Testr?r")
r8r�rv�negatedr)rvrwrur��arg_nodes
          r;rjzParser.parse_test�s����T�[�[�!���;�;���#�#�J�/�������G��G��{�{�!�!�&�)�/�/���k�k�!�!�&�&�%�/�������C�$�+�+�,�,�V�4�:�:�:�:�D��k�k�!�!�&�&�%�/�!%�$��:����;�;���#�#�x�/�15�1E�1E�1G�.�D�&�(�J�
�[�[�
 �
 �
%�
%�*
�
��+�+�%�%�.�.�{�I�z�R��{�{�"�"�'�'�	�2��	�	�C�D��)�)�+�H��)�)�(�3�H��:�D��D��z�z��$��f�h�
�5�<�<�
����9�9�T�%�,�,�7�D��r=c����g�g��j}|�|jj|�d��fd�}	|j�r�|jj}|jdk(rT|j
r1|t
j|j
|j���t|j��n1|jdk(rIt|j�||jd���|jjd�n�|jdk(r�|�t|j�|�B|jjj|�r�|�|jj�SS|j�}t|t �r�j#|�n�j|�|jjd	�nt%d
��|jr���|�|�|jj��S#|�|jj�wwxYw)Nc����r>�dj}�jtj�dd|����dd�=yy)Nrrd)r?rMrr�)r?r��data_buffers ��r;�
flush_dataz#Parser.subparse.<locals>.flush_data�s<����$�Q��.�.�����E�L�L��Q���G�H���N�r=r�rd�variable_beginTr�r\�block_beginr]zinternal parsing error)r,N)rMr7r/rBr_rorr�r?r�r�r�r`rrrzr�rW�extend�AssertionError)r8rU�add_datar�rvrir�r�s      @@r;r�zParser.subparse�s����$&��*,���%�%���!��!�!�(�(��4�	#�	,��+�+����+�+���:�:��'��{�{� ��!3�!3�E�K�K����!U�V�����%��Z�Z�#3�3�����%��T�-�-�D�-�A�B��K�K�&�&�~�6��Z�Z�=�0��L�����%�!�-�2N�$�+�+�2E�2E�2N�2N�#�3� $��%��%�%�)�)�+�&��-�-�/�B�!�"�d�+����B�����B���K�K�&�&�{�3�(�)A�B�B�1�+�+�4
�L��%��%�%�)�)�+�����%��%�%�)�)�+�&�s�D/H"�A6H"�=H"�"Ic��tj|j�d��}|j|j�|S)z0Parse the whole template into a `Template` node.rrd)r�Templater��set_environmentr')r8r�s  r;r4zParser.parses1������
�
���:�����t�/�/�0��
r=)NNNr�)NN)F)..)TFNF)T)FTNF)_r
�
__module__�__qualname__�__doc__�str�t�Optionalr<r�int�TyperCr\rXrRrTrYr�rarrgrj�Unionrhrzr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r
r�r�r�r�r�r�r�rr�r�rsr�rtr�r�r�r��typing�overloadrr�rrWr�rrrrr#r'r.r3r7r:rr�rRrarSr@rArlrmrdrnryr�rer�rjr�r�r4rr=r;r&r&.sD���!%�$(�!%�
>�"�>��>��j�j��o�	>�
�*�*�S�/�>��z�z�#��
>�
�>�4#'�+>�	9�
�9��
�
�3��9��V�V�'�
(�	9�

�9�&-��j�j��o�&-��������S�� 1�2�&-��
�
�3��	&-�

�&-�R48�?��?�!"���C��?�	�?�59�"&�	/��J�J�q�w�w�s�C�x�0�1�	/��
�
�3��	/�
�		/�@D�� �z�z�!�'�'�#�s�(�*;�<��	
���a�j�j��o���AS�AS��&�������Q�V�V�E�J�J�5G�)G�!H�&�<BG���'�'�#�s�(�+��:>��	
����
�
�	��:	K�1�7�7�5�<�<��1B�1B�#B�C�	K�T�5�9�9�T�&�%�(�(��$�E�J�J��"#�%�+�+�#��U�[�[��<�u�}�}��

�"�
�-1�
�	�
�
5�u�}�}�
5�6�e�l�l�6�(�E�,�,�(�T%�J�%�4�%� 
�%�/�/�
��E�$5�$5���U�[�[���U�\�\���_�_�FI����1C��	������
�_�_� ��9=�$���������A�G�G�C��H�$5�6�	�
��
������e�j�j�%�+�+�5�	6�
��� ��9=�$�(��(��(����A�G�G�C��H�$5�6�	(�
�(�
������e�j�j�%�+�+�5�	6�
(�T�d��e�j�j��
��
�
�
��%�*�*���5�:�:��$�5�:�:�$�7�u�z�z�7�.	�U�Z�Z�	�1�e�j�j�1�	�U�Z�Z�	��5�:�:���t��u�z�z��$ �u�z�z� �H!�"�9=�%*�@8��@8��@8����A�G�G�C��H�$5�6�	@8�
#�@8�
������e�j�j�(�	)�
@8�D
6�E�J�J�
6�
6�E�J�J�
6��%�*�*������
�e�j�j�
�U�Z�Z�
�A��J�J�A�	
�������
�
�-�	.�A�>1�%�*�*�1�@/2����/2�bY�u�z�z�Y�e�j�j�Y�BG���J�J�u�z�z�*��:>��	
���E�J�J�	��.$�u�z�z�$�e�j�j�$�N;?�/��*�*�Q�W�W�S�#�X�%6�7�/�	
����
�
�	�/�b�u�~�~�r=r&)'r�r�r�rKr�
exceptionsrr�lexerrr�
TYPE_CHECKING�typing_extensions�ter'r	�TypeVarr�r�r
r�r�r�	frozensetrpr(�Add�Sub�Mul�Div�FloorDiv�Modr$rar�r�rW�__annotations__r&rr=r;�<module>r�s���>�
���.�+�!�&��?�?�"�(�����+�U�\�\�5�=�=�I��
�Q�Y�Y�|�U�[�[�%�/�/�
B�
��
��� �G�H���9�9��9�9��9�9��9�9�����9�9�
0��Q�V�V�C�����
�
�+�+�
,��Z�Zr=