
    ,h                     >   U d Z ddlZddlZddlmZ ddlmZ ddlmZ ddlm	Z	 ddlm
Z
 ej                  r
ddlZdd	lmZ  ej                   d
ej"                  ej$                        Z ej                   dej(                  ej*                        Z eg d      Z eg d      Zej4                  ej6                  ej8                  ej:                  ej<                  ej>                  dZ ejB                  e"ejF                  ejH                     f   e%d<    G d 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                   "   e Zd ZdZ	 	 	 dSdddedej                  e   dej                  e   dej                  e   d	dfd
Zdefdedej                  e	   dej                  e   d	dfdZdej                  e   dej                  ej                  edf      dej                  e	   d	dfdZ	 dTdedej                  e	   d	dfdZ	 	 dUdej                  ej                  edf      dej                  e	   d	dfdZ	 dTdej                  ej                  edf      d	efdZdTdej                  e	   d	ej(                  fdZd	ej,                  ej.                  ej                  ej.                     f   fdZ	 dVdej                  edf   ded	ej                  ej.                     fdZd	ej,                  ej4                  ej6                  f   fdZd	ej:                  fdZd	ej>                  fdZ d	ejB                  fdZ"d	ejF                  fd Z$d	ejJ                  fd!Z&d	ejN                  fd"Z(d#e)d$ed	e)fd%Z*d	ejV                  fd&Z,d	ejZ                  fd'Z.d	ej^                  fd(Z0d#e1d	dfd)Z2d	ejf                  fd*Z4d	ejj                  fd+Z6d	ejn                  fd,Z8d	ejr                  fd-Z:e;jx                  	 dWd.ed/d0d	ejz                  fd1       Z>e;jx                  	 	 	 	 dXd.ed/edej                  ej                  edf      d2ed	ej,                  ej~                  ejz                  ej                  f   f
d3       Z>	 	 	 	 dXd.ed/edej                  ej                  edf      d2ed	ej,                  ej~                  ejz                  ej                  f   f
d4Z>dYd5ed	ej                  fd6ZAd	ej                  fd7ZBd	ej                  fd8ZCd	ej                  fd9ZDd	ej                  fd:ZEd	ej                  fd;ZFd	ej                  fd<ZGd	ej                  fd=ZHd	ej                  fd>ZId	ej                  fd?ZJdYd@ed	ej                  fdAZKdVd2ed	ej                  fdBZL	 	 	 	 	 dZdCed5edej                  ej                  edf      dDed2ed	ej,                  ej                  ej                  f   fdEZMd	ej                  fdFZNd	ej                  fdGZPd#ej                  d	ej                  fdHZQd#ej                  d	ej                  fdIZRd#ej                  d	ej,                  ej                  ej                  f   fdJZUd	ej                  fdKZVd	ej                  ej                  ej                     ej                  ej                     ej                  ej                     ej                  ej                     f   fdLZXd#ej                  d	ej                  fdMZZ	 dVd#ej                  ej                     dNed	ej                  ej                     fdOZ[d#ej                  d	ej                  fdPZ\	 dTdej                  ej                  edf      d	ej                  ej.                     fdQZ]d	ej                  fdRZ_y)[ParserzThis 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 ],  }|j                  D ]  }|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           O/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/jinja2/parser.py__init__zParser.__init__5   s     '!++FD(EJ	   	 %446 	7I ~~ 7'0$7	7 !"');=    msglinenoexczte.NoReturnc                     | | j                   j                  j                  } |||| j                  | j                        )zConvenience 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*   )r8   r>   r?   r@   s       r;   failzParser.failL   s7     >[[((//F#vtyy$--88r=   end_token_stack.c           
         t               }|D ]!  }|j                  t        t        |             # |r1dj	                  t        t
        t        t        |d                     }nd }|dg}nd|dg}|r1|||v r|j                  d| d       n|j                  d| d       | j                  r"|j                  d| j                  d   d       | j                  d	j	                  |      |       y )
Nz or zUnexpected end of template.zEncountered 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appendr6   rC   )r8   r)   rD   r?   expectedexprscurrently_lookingmessages           r;   _fail_ut_eofzParser._fail_ut_eofZ   s     #u$ 	=EOOC 3U;<	=17D#1?23FGH2 !%<45G1$;<GDH$422C1DAG
 @AR@SSTU ??NNOOB'*!-
 			#((7#V,r=   c                 >    | j                  || j                  |       y)zCalled if the parser encounters an unknown tag.  Tries to fail
        with a human readable error message that could help to identify
        the problem.
        N)rR   r7   )r8   r)   r?   s      r;   fail_unknown_tagzParser.fail_unknown_tag   s     	$ 5 5v>r=   
end_tokensc                 z    t        | j                        }||j                  |       | j                  d||       y)z9Like fail_unknown_tag but for end of template situations.N)listr7   rM   rR   )r8   rU   r?   stacks       r;   fail_eofzParser.fail_eof   s8     T**+!LL$$v.r=   extra_end_rulesc                     | j                   j                  j                  dv ry|%| j                   j                  j                  |      S y)zAre we at the end of a tuple?)variable_end	block_endrparenTF)r/   rB   typetest_any)r8   rZ   s     r;   is_tuple_endzParser.is_tuple_end   sD     ;;##'NN(;;&&//@@r=   c                     | xj                   dz  c_         t        j                  t        j                        }t        j
                  j                  |d| j                    |       |S )zDReturn a new free identifier as :class:`~jinja2.nodes.InternalName`.r   fir?   )r5   object__new__r   InternalNameNoder<   )r8   r?   rvs      r;   free_identifierzParser.free_identifier   sS    "^^E../

B"T%:%:$; <VL	r=   c                 &   | j                   j                  }|j                  dk7  r| j                  d|j                         | j
                  j                  |j                         d}	 |j                  t        v rQt        | d| j                   j                  j                         } |       |r| j
                  j                          S S |j                  dk(  r-| j                         |r| j
                  j                          S S |j                  dk(  r-| j                         |r| j
                  j                          S S | j                  j                  |j                        }|% ||       |r| j
                  j                          S S | j
                  j                          d}| j                  |j                  |j                         |r| j
                  j                          yy# |r| j
                  j                          w w xY w)	zParse a single statement.r)   ztag name expectedTparse_callfilterNF)r/   rB   r_   rC   r?   r6   rM   value_statement_keywordsgetattrpopparse_call_blockparse_filter_blockr1   getrT   )r8   tokenpop_tagfexts        r;   parse_statementzParser.parse_statement   s   ##::II)5<<8u{{+	&{{11DF4;;+>+>+D+D*E"FGs  ##%  {{f$,,. ##%  {{h&..0 ##%  //%%ekk2C4y ##% 	 OO!G!!%++u||<##% w##% s&   *AG1 G1 	G1 .G1 AG1 1Hdrop_needlec                 *   | j                   j                  d       | j                   j                  d       | j                  |      }| j                   j                  j
                  dk(  r| j                  |       |rt        | j                          |S )aR  Parse 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subparserB   r_   rY   next)r8   rU   r{   results       r;   parse_statementszParser.parse_statements   sr     	G$ 	;'z* ;;##u,MM*%r=   c                 d   t        | j                        j                  }| j                  d      }| j                  j	                  d      r(| j                         }t        j                  |||      S | j                  d      }| j                  dd      }t        j                  ||||      S )zParse an assign statement.Twith_namespaceassignrd   N)zname:endsetr{   )r   r/   r?   parse_assign_targetr   parse_tupler   Assignparse_filterr   AssignBlock)r8   r?   targetexprfilter_nodebodys         r;   	parse_setzParser.parse_set   s    dkk")))))>;;x(##%D<<V<<''-$$%54$H  d6JJr=   c           	      &   | j                   j                  d      j                  }| j                  d      }| j                   j                  d       | j	                  dd      }d}| j                   j                  d	      r| j                         }| j                   j                  d
      }| j                  d      }t        | j                         j                  dk(  rg }n| j                  dd      }t        j                  |||||||      S )zParse a for loop.zname:for)name:in)rZ   r   F)name:recursive)with_condexprrZ   Nname:ifr   )name:endfor	name:elseendfor)r   Tr   rd   )r/   r   r?   r   r   r   parse_expressionr   r   ro   r   For)r8   r?   r   itertest	recursiver   else_s           r;   	parse_forzParser.parse_for   s    ##J/66)),)G9%1D   
 ;;y)((*DKK''(89	$$%AB""h.E))*:)MEyytUD)FSSr=   c                 4   t        j                  | j                  j                  d      j                        x}}	 | j                  d      |_        | j                  d      |_        g |_	        g |_
        t        | j                        }|j                  d      rPt        j                  | j                  j                  j                        }|j                  j                  |       |j                  d      r| j                  d	d
      |_
        	 |S )zParse an if construct.r   rd   TFr   )	name:elifr   
name:endifr   r   )r   r   )r   Ifr/   r   r?   r   r   r   r   elif_r   r   rB   rM   )r8   noder   rv   s       r;   parse_ifzParser.parse_if   s    (:(:9(E(L(LMMv((u(=DI--.VWDIDJDJ%Ezz+&xxt{{':':'A'AB##D)K(#44_RV4Wr=   c                 `   t        j                  t        | j                        j                        }g }g }| j                  j
                  j                  dk7  r|r| j                  j                  d       | j                         }|j                  d       |j                  |       | j                  j                  d       |j                  | j                                | j                  j
                  j                  dk7  r||_        ||_        | j                  dd      |_        |S )	Nrd   r]   commaparamr   )zname:endwithTr   )r   Withr   r/   r?   rB   r_   r   r   set_ctxrM   r   targetsvaluesr   r   )r8   r   r   r   r   s        r;   
parse_withzParser.parse_with  s    zzdkk!2!9!9:&(%'kk!!&&+5""7+--/FNN7#NN6"KKx(MM$//12 kk!!&&+5 ))*;)N	r=   c                    t        j                  t        | j                        j                        }t        j
                  d| j                               g|_        | j                  dd      |_	        t        j                  |g      S )Nrd   r   )zname:endautoescapeTr   )r   ScopedEvalContextModifierr   r/   r?   Keywordr   optionsr   r   Scoper8   r   s     r;   parse_autoescapezParser.parse_autoescape"  sh    ..d4;;6G6N6NOlD4I4I4KLM))*At)T	{{D6""r=   c                    t        j                  t        | j                        j                        }| j                  j                  d      j                  |_        | j                  j                  d      |_	        | j                  j                  d      |_
        | j                  j                  j                  dk(  r| j                  d       | j                  dd	      |_        |j                  rY|j                  D ]J  }t!        |t         j"                        rt%        d
 |j                   D              s:| j                  d       L | j                  j                  d|j                  z          |S )Nrd   r)   zname:scopedzname:requiredr   zpBlock names in Jinja have to be valid Python identifiers and may not contain hyphens, use an underscore instead.)zname:endblockTr   c              3      K   | ]<  }t        |t        j                         xs |j                  j	                           > y wN)
isinstancer   TemplateDatadataisspace).0output_nodes     r;   	<genexpr>z%Parser.parse_block.<locals>.<genexpr>>  sK      B $ #;0B0BCC 6&++33556Bs   AAz7Required blocks can only contain comments or whitespacezname:)r   Blockr   r/   r?   r   ro   r)   r   scopedrequiredrB   r_   rC   r   r   r   Outputany)r8   r   	body_nodes      r;   parse_blockzParser.parse_block(  s%   {{$t{{"3":":;KK&&v.44	kk))-8++O<
 ;;##u,II?
 ))*<$)O	
 ==!YY Y	!)U\\:c B (1B ?
 IIWXY 	Gdii/0r=   c                     t        j                  t        | j                        j                        }| j                         |_        |S Nrd   )r   Extendsr   r/   r?   r   templater   s     r;   parse_extendszParser.parse_extendsH  s4    }}D$5$<$<=--/r=   r   defaultc                 8   | j                   j                  j                  dd      rl| j                   j                         j	                  d      rCt        | j                         j                  dk(  |_        | j                   j                          |S ||_        |S )Nz	name:withzname:withoutname:contextr   )	r/   rB   r`   lookr   r   ro   with_contextskip)r8   r   r   s      r;   parse_import_contextzParser.parse_import_contextM  s~     ;;''
kk %%n5 $T[[ 1 7 76 ADKK  !(Dr=   c                    t        j                  t        | j                        j                        }| j                         |_        | j                  j                  j                  d      rL| j                  j                         j                  d      r#d|_
        | j                  j                  d       nd|_
        | j                  |d      S )Nrd   zname:ignorezname:missingT   F)r   Includer   r/   r?   r   r   rB   r   r   ignore_missingr   r   r   s     r;   parse_includezParser.parse_includeY  s    }}D$5$<$<=--/;;##M2t{{7G7G7I7N7N8
 #'DKKQ"'D((t44r=   c                 .   t        j                  t        | j                        j                        }| j                         |_        | j                  j                  d       | j                  d      j                  |_
        | j                  |d      S )Nrd   name:asT	name_onlyF)r   Importr   r/   r?   r   r   r   r   r)   r   r   r   s     r;   parse_importzParser.parse_importe  so    ||4#4#;#;<--/9%...>CC((u55r=   c                     t        j                  t         j                        j                         j                         _         j                  j                  d       g _        dt        f fd}	 j                  r j                  j                  d        j                  j                  j                  dk(  r |       rn j                  d      }|j                  j                  d	      r" j                  d
|j                  t                 j                  j#                  d      rD j                  d      }j                  j%                  |j                  |j                  f       n%j                  j%                  |j                          |       s# j                  j                  j                  dk7  rn j                  j                  d       ot'        d      sd_        S )Nrd   zname:importr,   c                      j                   j                  j                  dv rkj                   j                         j	                  d      rBt        j                         j                  dk(   _        j                   j                          yy)N>   r   withoutr   r   TF)r/   rB   ro   r   r   r   r   r   )r   r8   s   r;   parse_contextz(Parser.parse_from.<locals>.parse_contextr  so    {{""(( -  ++""$)).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boolrB   r_   r   r)   
startswithrC   r   r   rM   hasattrr   )r8   r   r   aliasr   s   `   @r;   
parse_fromzParser.parse_froml  s   tDKK'8'?'?@--/=)
	t 	 zz""7+{{""''61 ?11D1A;;))#.IIN2  
 ;;&&y1 44t4DEJJ%%v{{EJJ&?@JJ%%fkk2 ?dkk&9&9&>&>'&I""6*+ , t^, %Dr=   c                 `   g x}|_         g x}|_        | j                  j                  d       | j                  j                  j
                  dk7  r|r| j                  j                  d       | j                  d      }|j                  d       | j                  j                  d      r |j                  | j                                n|r| j                  d       |j                  |       | j                  j                  j
                  dk7  r| j                  j                  d       y )	Nlparenr^   r   Tr   r   r   z-non-default argument follows default argument)argsdefaultsr/   r   rB   r_   r   r   r   rM   r   rC   )r8   r   r   r   args        r;   parse_signaturezParser.parse_signature  s    ty#%%4=8$kk!!&&(2""7+**T*:CKK {{""8, 5 5 78		IJKK kk!!&&(2 	8$r=   c                    t        j                  t        | j                        j                        }| j                  j
                  j                  dk(  r| j                  |       ng |_        g |_	        | j                         }t        |t         j                        s| j                  d|j                         ||_        | j                  dd      |_        |S )Nrd   r   zexpected call)zname:endcallTr   )r   	CallBlockr   r/   r?   rB   r_   r   r   r   r   r   CallrC   rm   r   r   )r8   r   	call_nodes      r;   rs   zParser.parse_call_block  s    d4;;&7&>&>?;;##x/  &DIDM))+	)UZZ0IIot{{3	))*;)N	r=   c                     t        j                  t        | j                        j                        }| j                  d d      |_        | j                  dd      |_        |S )Nrd   T)start_inline)zname:endfilterr   )	r   FilterBlockr   r/   r?   r   rn   r   r   r   s     r;   rt   zParser.parse_filter_block  sU      T[[(9(@(@A''4'@))*=4)P	r=   c                     t        j                  t        | j                        j                        }| j                  d      j                  |_        | j                  |       | j                  dd      |_	        |S )Nrd   Tr   )zname:endmacror   )
r   Macror   r/   r?   r   r)   r   r   r   r   s     r;   parse_macrozParser.parse_macro  se    {{$t{{"3":":;,,t,<AA	T"))*<$)O	r=   c                    t        j                  t        | j                        j                        }g |_         | j                  j
                  j                  dk7  rt|j                   r| j                  j                  d       |j                   j                  | j                                | j                  j
                  j                  dk7  rt|S )Nrd   r]   r   )
r   r   r   r/   r?   rB   r_   r   rM   r   r   s     r;   parse_printzParser.parse_print  s    ||4#4#;#;<
kk!!&&+5zz""7+JJd3356 kk!!&&+5 r=   
with_tupler   zte.Literal[True]c                      y r    )r8   r   r   s      r;   r   zParser.parse_assign_target  s     r=   r   c                      y r   r  )r8   r   r   rZ   r   s        r;   r   zParser.parse_assign_target  s     9<r=   c                    |rH| j                   j                  d      }t        j                  |j                  d|j
                        }n:|r| j                  d||      }n| j                  |      }|j                  d       |j                         s@| j                  dt        |      j                  j                         |j
                         |S )a  Parse 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.
        r)   storerd   T)
simplifiedrZ   r   r   zcan't assign to )r/   r   r   Namero   r?   r   parse_primaryr   
can_assignrC   r_   __name__lower)r8   r   r   rZ   r   rv   r   s          r;   r   zParser.parse_assign_target  s    " KK&&v.EZZWU\\JF))#$3#1 *  ++>+JNN7#  "II"4<#8#8#>#>#@"CDfmm r=   r   c                 F    |r| j                         S | j                         S )zParse 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r8   r   s     r;   r   zParser.parse_expression   s"    
 &&((}}r=   c                    | j                   j                  j                  }| j                         }| j                   j	                  d      r| j                         }| j                   j	                  d      r| j                         }nd }t        j                  ||||      }| j                   j                  j                  }| j                   j	                  d      r|S )Nr   r   rd   )r/   rB   r?   r  r   r  r   CondExpr)r8   r?   expr1expr2expr3s        r;   r  zParser.parse_condexpr	  s    $$++ kk!!),MMOE{{"";/++-NN5%vFE[[((//F kk!!), r=   c                 d   | j                   j                  j                  }| j                         }| j                   j	                  d      rd| j                         }t        j                  |||      }| j                   j                  j                  }| j                   j	                  d      rd|S )Nname:orrd   )r/   rB   r?   	parse_andr   r   Orr8   r?   leftrights       r;   r  zParser.parse_or  s    $$++~~kk!!),NN$E88D%7D[[((//F kk!!), r=   c                 d   | j                   j                  j                  }| j                         }| j                   j	                  d      rd| j                         }t        j                  |||      }| j                   j                  j                  }| j                   j	                  d      rd|S )Nname:andrd   )r/   rB   r?   	parse_notr   r   Andr  s       r;   r  zParser.parse_and!  s    $$++~~kk!!*-NN$E99T58D[[((//F kk!!*- r=   c                     | j                   j                  j                  d      rDt        | j                         j                  }t        j                  | j                         |      S | j                         S )Nname:notrd   )	r/   rB   r   r   r?   r   Notr  parse_compare)r8   r?   s     r;   r  zParser.parse_not*  sU    ;;##J/$++&--F99T^^-f==!!##r=   c                    | j                   j                  j                  }| j                         }g }	 | j                   j                  j                  }|t
        v rIt        | j                          |j                  t        j                  || j                                      n| j                   j                  d      r4|j                  t        j                  d| j                                      n| j                   j                  j                  d      rx| j                   j                         j                  d      rO| j                   j                  d       |j                  t        j                  d| j                                      nn"| j                   j                  j                  }|s|S t        j                  |||      S )Nr   inr!  r   notinrd   )r/   rB   r?   parse_math1r_   _compare_operatorsr   rM   r   Operandr   r   r   r   Compare)r8   r?   r   ops
token_types        r;   r#  zParser.parse_compare0  sL   $$++!,,11J//T[[!

5==T5E5E5GHI$$Y/

5==t/?/?/ABC$$))*5$++:J:J:L:Q:Q;   #

5==$2B2B2DEF[[((//F  K}}T3v66r=   c                    | j                   j                  j                  }| j                         }| j                   j                  j                  dv rt
        | j                   j                  j                     }t        | j                          | j                         } ||||      }| j                   j                  j                  }| j                   j                  j                  dv r|S )N)r   r   rd   )r/   rB   r?   parse_concatr_   r$   r   r8   r?   r  clsr  s        r;   r'  zParser.parse_math1G  s    $$++  "kk!!&&.8dkk11667C%%'EtU62D[[((//F kk!!&&.8 r=   c                    | j                   j                  j                  }| j                         g}| j                   j                  j                  dk(  rXt        | j                          |j                  | j                                | j                   j                  j                  dk(  rXt        |      dk(  r|d   S t        j                  ||      S )Ntilder   r   rd   )
r/   rB   r?   parse_math2r_   r   rM   lenr   Concat)r8   r?   r   s      r;   r.  zParser.parse_concatR  s    $$++  "#kk!!&&'1KK((*+ kk!!&&'1 t9>7N||D00r=   c                    | j                   j                  j                  }| j                         }| j                   j                  j                  dv rt
        | j                   j                  j                     }t        | j                          | j                         } ||||      }| j                   j                  j                  }| j                   j                  j                  dv r|S )N)r    r!   r"   r#   rd   )r/   rB   r?   	parse_powr_   r$   r   r/  s        r;   r3  zParser.parse_math2\  s    $$++~~kk!!&&*KKdkk11667CNN$EtU62D[[((//F kk!!&&*KK r=   c                    | j                   j                  j                  }| j                         }| j                   j                  j                  dk(  rt        | j                          | j                         }t        j                  |||      }| j                   j                  j                  }| j                   j                  j                  dk(  r|S )Npowrd   )r/   rB   r?   parse_unaryr_   r   r   Powr  s       r;   r7  zParser.parse_powg  s    $$++!kk!!&&%/$$&E99T58D[[((//F	 kk!!&&%/
 r=   with_filterc                    | j                   j                  j                  }| j                   j                  j                  }|dk(  r<t	        | j                          t        j                  | j                  d      |      }nQ|dk(  r<t	        | j                          t        j                  | j                  d      |      }n| j                         }| j                  |      }|r| j                  |      }|S )Nr   Frd   r   )r/   rB   r_   r?   r   r   Negr:  Posr  parse_postfixparse_filter_expr)r8   r<  r,  r?   r   s        r;   r:  zParser.parse_unaryq  s    [[((--
$$++ 99T--e4VDD5 99T--e4VDD%%'D!!$'))$/Dr=   c                    | j                   j                  }|j                  dk(  r>t        | j                          |j                  dv r/t        j                  |j                  dv |j                        }|S |j                  dv r#t        j                  d|j                        }|S |r| j                   j                  j                  dk(  rht        | j                          | j                   j                  d      }t        j                  |j                  |j                  |j                        }|S t        j                  |j                  d|j                        }|S |j                  d	k(  rt        | j                          |j                  g}|j                  }| j                   j                  j                  d	k(  rh|j                  | j                   j                  j                         t        | j                          | j                   j                  j                  d	k(  rht        j                  d
j                  |      |      }|S |j                  dv rBt        | j                          t        j                  |j                  |j                        }|S |j                  dk(  rDt        | j                          | j                  d      }| j                   j                  d       |S |j                  dk(  r| j                         }|S |j                  dk(  r| j                         }|S | j!                  dt#        |      |j                         S )zParse a name or literal value. If ``with_namespace`` is enabled, also
        parse namespace attr refs, for use in assignments.r)   )truefalseTrueFalse)rC  rE  rd   )noneNoneNdotloadstring )integerfloatr   T)explicit_parenthesesr^   lbracketlbracezunexpected )r/   rB   r_   r   ro   r   Constr?   r   NSRefr  rM   rK   r   
parse_list
parse_dictrC   r   )r8   r   rv   r   attrbufr?   s          r;   r  zParser.parse_primary  s    ##::{{@@{{5;;2B#B5<<X@ ?  00{{4=< ;  DKK$7$7$<$<$E T[[!{{))&1{{5;;

5<<P0 - zz%++vellK, + ZZ8#;;-C\\F++%%**h6

4;;..445T[[! ++%%**h6 ;;rwws|F;D  ZZ//;;u{{5<<@D  ZZ8####>DKKx(  ZZ:%??$D
 	 ZZ8#??$D  IIN5$9#<=u||Lr=   r  rO  c                 v     j                   j                  j                  }|rdt        j                  f fd}ndt        j                  f fd}g }d}		 |r j                   j                  d        j                  |      rn^|j                   |               j                   j                  j                  dk(  rd}	nn! j                   j                  j                  }|	s:|r|d   S |s1 j                  dt         j                   j                               t        j                  |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; ``with_namespace`` allows namespace
        attr refs as well. 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                  (     j                        S )Nr   )r  )r8   r   s   r;   r4   z!Parser.parse_tuple.<locals>.parse  s    )))HHr=   c                  (     j                        S )Nr   )r   r  s   r;   r4   z!Parser.parse_tuple.<locals>.parse  s    ,,=,IIr=   FTr   r   zExpected an expression, got rJ  rd   )r/   rB   r?   r   Exprr   ra   rM   r_   rC   r   Tuple)
r8   r  r   rZ   rO  r   r?   r4   r   is_tuples
   ` `  `    r;   r   zParser.parse_tuple  s   6 $$++I5:: I
J5:: J $&""7+  1KK {{""''72[[((//F  Aw (		*4;;+>+>?BD
 {{477r=   c                    | j                   j                  d      }g }| j                   j                  j                  dk7  r|r| j                   j                  d       | j                   j                  j                  dk(  rnC|j	                  | j                                | j                   j                  j                  dk7  r| j                   j                  d       t        j                  ||j                        S )NrP  rbracketr   rd   )	r/   r   rB   r_   rM   r   r   Listr?   )r8   rv   itemss      r;   rT  zParser.parse_list  s    "":.$&kk!!&&*4""7+{{""'':5LL..01 kk!!&&*4 	:&zz%55r=   c                    | j                   j                  d      }g }| j                   j                  j                  dk7  r|r| j                   j                  d       | j                   j                  j                  dk(  rn| j	                         }| j                   j                  d       | j	                         }|j                  t        j                  |||j                               | j                   j                  j                  dk7  r| j                   j                  d       t        j                  ||j                        S )NrQ  rbracer   r}   rd   )
r/   r   rB   r_   r   rM   r   Pairr?   Dict)r8   rv   ra  keyro   s        r;   rU  zParser.parse_dict  s    ""8,$&kk!!&&(2""7+{{""''83'')CKKw'))+ELLCszzBC kk!!&&(2 	8$zz%55r=   c                     	 | j                   j                  j                  }|dk(  s|dk(  r| j                  |      }n|dk(  r| j	                  |      }n	 |S W)NrI  rP  r   )r/   rB   r_   parse_subscript
parse_callr8   r   r,  s      r;   r@  zParser.parse_postfix  s^    ,,11JU"jJ&>++D1 x't, r=   c                    	 | j                   j                  j                  }|dk(  r| j                  |      }nT|dk(  r5| j                   j                  j                  dk(  r| j                  |      }n|dk(  r| j                  |      }n	 |S )Npiper)   isr   )r/   rB   r_   r   ro   
parse_testri  rj  s      r;   rA  zParser.parse_filter_expr  s    ,,11JV#((.v%$++*=*=*C*Ct*Kt, x't, r=   c                 T   t        | j                        }|j                  dk(  r| j                  j                  }t        | j                         |j                  dk(  r-t	        j
                  ||j                  d|j                        S |j                  dk7  r| j                  d|j                         t	        j                  |j                  |j                        }t	        j                  ||d|j                        S |j                  dk(  rg }| j                  j                  j                  dk7  r`|r| j                  j                  d	       |j                  | j                                | j                  j                  j                  dk7  r`| j                  j                  d       t        |      d
k(  r|d   }n"t	        j                  |d|j                        }t	        j                  ||d|j                        S | j                  d|j                         y )NrI  r)   rJ  rd   rM  zexpected name or numberrP  r_  r   r   r   zexpected subscript expression)r   r/   r_   rB   r   Getattrro   r?   rC   rR  Getitemr   rM   parse_subscribedr4  r\  )r8   r   rv   
attr_tokenr   r   s         r;   rh  zParser.parse_subscript)  s    T[[! ::,,J&(}}***F5<<  I-		3Z5F5FG++j..z7H7HIC==sF5<<HH::#')D++%%**j8KK&&w/D1134 ++%%**j8 KKz*4yA~1gkk$u||D==sF5<<HH		15<<@r=   c                    | j                   j                  j                  }| j                   j                  j                  dk(  rt	        | j                          d g}nM| j                         }| j                   j                  j                  dk7  r|S t	        | j                          |g}| j                   j                  j                  dk(  r|j                  d        nS| j                   j                  j                  dvr |j                  | j                                n|j                  d        | j                   j                  j                  dk(  rit	        | j                          | j                   j                  j                  dvr |j                  | j                                n#|j                  d        n|j                  d        t        j                  |d|iS )Nr}   )r_  r   r?   )	r/   rB   r?   r_   r   r   rM   r   Slice)r8   r?   r   r   s       r;   rr  zParser.parse_subscribedH  s^   $$++ ;;##w.6D((*D{{""''726D;;##w.KK[[  %%-BBKK--/0KK;;##w.{{""''/DDD1134D!KK{{40&00r=   c                 0   	  j                   j                  d      	g }g }d }d }d}dt        dd f 	fd} j                   j                  j                  dk7  r|r@ j                   j                  d        j                   j                  j                  dk(  rnډ j                   j                  j                  dk(  r7 ||d u xr |d u        t         j                           j                         }nY j                   j                  j                  d	k(  r1 ||d u        t         j                           j                         }n j                   j                  j                  d
k(  r j                   j                         j                  dk(  r ||d u         j                   j                  j                  } j                   j                  d        j                         }|j                  t        j                  |||j                               n4 ||d u xr	 |d u xr |        |j                   j                                d} j                   j                  j                  dk7  r j                   j                  d       ||||fS )Nr   Fr   r,   c                 D    | sj                  dj                         y y )Nz+invalid syntax for function call expression)rC   r?   )r   r8   rv   s    r;   ensurez&Parser.parse_call_args.<locals>.ensurew  s    		GV r=   r^   r   r    r9  r)   r   r   rd   T)r/   r   r   rB   r_   r   r   r   ro   r   rM   r   r   r?   )
r8   r   kwargsdyn_args
dyn_kwargsrequire_commarx  rf  ro   rv   s
   `        @r;   parse_call_argszParser.parse_call_argsh  s+    ""8,
	W 	W$ 	W kk!!&&(2""7+ ;;&&++x7{{""''50x4'>J$,>?T[[!002$$))U2zT)*T[[!!224
 KK'',,6((*//8; :-.++--33CKK$$Q' 113EMM%--U5<<"PQ 8t+Q
d0BQ6zRKK 5 5 78 MA kk!!&&(2D 	8$VXz11r=   c                     | j                   j                  }| j                         \  }}}}t        j                  ||||||j
                        S r   )r/   rB   r}  r   r   r?   )r8   r   rv   r   ry  rz  r{  s          r;   ri  zParser.parse_call  sG     ##-1-A-A-C*fh
zz$fh
5<<XXr=   r   c           	          | j                   j                  j                  dk(  s|rW|st        | j                          | j                   j	                  d      }|j
                  }| j                   j                  j                  dk(  rdt        | j                          |d| j                   j	                  d      j
                  z   z  }| j                   j                  j                  dk(  rd| j                   j                  j                  dk(  r| j                         \  }}}}ng }g }d x}}t        j                  |||||||j                        }d}| j                   j                  j                  dk(  rS|rW|S )Nrl  r)   rI  rG   r   rd   F)
r/   rB   r_   r   r   ro   r}  r   Filterr?   )	r8   r   r   rv   r)   r   ry  rz  r{  s	            r;   r   zParser.parse_filter  s<    kk!!&&&0LT[[!KK&&v.E;;D++%%**e3T[[!dkk008>>>> ++%%**e3 {{""''83595I5I5K2fh
(,,:<<dD&(Ju||D !L# kk!!&&&0L$ r=   c           	      b   t        | j                        }| j                  j                  j                  d      rt        | j                         d}nd}| j                  j	                  d      j
                  }| j                  j                  j                  dk(  rdt        | j                         |d| j                  j	                  d      j
                  z   z  }| j                  j                  j                  dk(  rdd x}}g }| j                  j                  j                  dk(  r| j                         \  }}}}n| j                  j                  j                  dv r| j                  j                  j                  d	d
d      s[| j                  j                  j                  d      r| j                  d       | j                         }	| j                  |	      }	|	g}ng }t        j                  |||||||j                        }|r!t        j                  ||j                        }|S )Nr!  TFr)   rI  rG   r   >   r)   rN  rQ  r   rK  rM  rP  r   r  r  zname:isz'You cannot chain multiple tests with isrd   )r   r/   rB   r   r   ro   r_   r}  r`   rC   r  r@  r   Testr?   r"  )
r8   r   rv   negatedr)   rz  r{  ry  r   arg_nodes
             r;   rn  zParser.parse_test  s   T[[!;;##J/GG{{!!&)//kk!!&&%/C$++,,V4::::D kk!!&&%/ !%$:(*;;##x/151E1E1G.D&(J[[  %% *
 
 ++%%..{IzR{{""''	2		CD))+H))(3H:DDzz$fh
5<<
 99T%,,7Dr=   c                    g g j                   }|| j                  j                  |       dfd}	 | j                  r| j                  j                  }|j                  dk(  rT|j
                  r1 |t        j                  |j
                  |j                               t        | j                         n1|j                  dk(  rIt        | j                          || j                  d             | j                  j                  d       n|j                  dk(  r |        t        | j                         |B | j                  j                  j                  | r|| j                  j                          S S | j                         }t        |t               rj#                  |       nj                  |       | j                  j                  d	       nt%        d
      | j                  r |        || j                  j                          S # || j                  j                          w w xY w)Nc                      r>d   j                   } j                  t        j                  d d  |              d d = y y )Nr   rd   )r?   rM   r   r   )r?   r   data_buffers    r;   
flush_dataz#Parser.subparse.<locals>.flush_data  s<    $Q..ELLQGHN r=   r   rd   variable_beginTr   r\   block_beginr]   zinternal parsing error)r,   N)rM   r7   r/   rB   r_   ro   r   r   r?   r   r   r   r`   rr   rz   r   rW   extendAssertionError)r8   rU   add_datar  rv   ri   r   r  s         @@r;   r   zParser.subparse  s    $&*,%%!!!((4	#	,++++::'{{ !3!3EKK!UV%ZZ#33%T--D-ABKK&&~6ZZ=0L%!-2N$++2E2E2N2N#3  $ %%%))+ & --/B!"d+BBKK&&{3()ABB1 ++4 L%%%))+ %%%))+ &s   D/H" A6H" =H" "Ic                     t        j                  | j                         d      }|j                  | j                         |S )z0Parse the whole template into a `Template` node.r   rd   )r   Templater   set_environmentr'   )r8   r   s     r;   r4   zParser.parse  s1    :t//0r=   )NNNr   )NN)F)..)TFNF)T)FTNFF)`r
  
__module____qualname____doc__strtOptionalr<   r   intTyperC   r`  r\  rR   rT   rY   r   ra   r   rg   rj   Unionrh   rz   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r
   r   r   r   r   r   r   r   r   r   r   rs   r   rt   r   r   r   r   typingoverloadr  r   rS  r[  r   r  r  r  r  r#  r'  r.  r3  r7  r:  r  r   rT  re  rU  r@  rA  rp  rq  rh  rr  r   r}  r   ri  r   rn  r   r  r4   r  r=   r;   r&   r&   0   s    !%$(!%>"> > jjo	>
 **S/> zz#> 
>4 #'+>	99 

39 VV'(	9
 
9&-jjo&- S 12&- 

3	&-
 
&-R 48??!"C?	? 59"&	/JJqwwsCx01	/ 

3	/ 
		/ @D zz!''#s(*;<	ajjo ASAS &QVVEJJ5G)G!H &< BG''#s(+:>	


	:	K1775<<1B1B#BC 	KT599 T&%(( $EJJ "#%++ #U[[ @u}} 

"
-1
	

5u}} 
56ell 6(E,, (T%J %4 % %// E$5$5 U[[ U\\  __FI1C	  __  9=$<< < AGGCH$56	<
 < 
ejj%++5	6< <  9=$%% % AGGCH$56	%
 % 
ejj%++5	6%Nd ejj 

 %** 5:: $5:: $7uzz 7.	UZZ 	1ejj 1	UZZ 	5:: t uzz $(D (UZZ (X !"9=%*$C8C8 C8 AGGCH$56	C8
 #C8 C8 
ejj(	)C8J
6EJJ 
66EJJ 6%**  ejj UZZ AJJA	
-	.A>1%** 1@62	
	uzz	u}}	

5::	

5::	 
62pYuzz Yejj Y BGJJuzz*:>	
EJJ	.$uzz $ejj $N ;?/**QWWS#X%67/	


	/bu~~ r=   r&   )'r  r  r  rL  r   
exceptionsr   r   lexerr   r   TYPE_CHECKINGtyping_extensionster'   r	   TypeVarr   r   r
   r   r   r   	frozensetrp   r(  AddSubMulDivFloorDivModr$   re  r  r  r[  __annotations__r&   r  r=   r;   <module>r     s    >    . + ! &??"(+U\\5==IQYY|U[[%//B
   GH  99999999990QVVC

++, i ir=   