3

U'ícW›ã
@s
UdZddlZddlZddlmZddlmZddlmZddlm	Z	ddlm
Z
ejrlddlZ
dd	lmZejd
ejejƒZejdejejƒZedd
ddddddddddgƒZeddddddgƒZejejejejejejdœZ ej!e"ej#ej$f Gdd „d ƒZ%dS)!z8Parse tokens from the lexer into nodes for the compiler.éNé)Únodes)ÚTemplateAssertionError)ÚTemplateSyntaxError)Údescribe_token)Údescribe_token_expr)ÚEnvironmentÚ_ImportIncludeÚ
_MacroCallÚforÚifÚblockZextendsÚprintÚmacroÚincludeÚfromÚimportÚsetÚwithÚ
autoescapeÚeqÚneÚltZlteqÚgtZgteq)ÚaddÚsubÚmulÚdivÚfloordivÚmodc
@s
eZdZdZdƒdeejeejeejeddœdd„Zdefeeje	ej
eddœd	d
„Zejeejej
edfeje	ddœd
d„Zd„eeje	ddœdd„Zd…ejej
edfeje	ddœdd„Zd†ejej
edfedœdd„Zd‡eje	ejdœdd„Zejejejejfdœdd„Zdˆej
edfeejejdœd d!„Zejejejfdœd"d#„Zejdœd$d%„Zejdœd&d'„Z ej!dœd(d)„Z"ej#dœd*d+„Z$ej%dœd,d-„Z&ej'dœd.d/„Z(e)ee)d0œd1d2„Z*ej+dœd3d4„Z,ej-dœd5d6„Z.ej/dœd7d8„Z0e1dd9œd:d;„Z2ej3dœd<d=„Z4ej5dœd>d?„Z6ej7dœd@dA„Z8ej9dœdBdC„Z:e;j<d‰edDej=dEœdFdG„ƒZ>e;j<dŠeeejej
edfeejej?ej=ej
fdIœdJdG„ƒZ>d‹eeejej
edfeejej?ej=ej
fdIœdKdG„Z>dŒeej@dLœdMdN„ZAej@dœdOdP„ZBej@dœdQdR„ZCej@dœdSdT„ZDej@dœdUdV„ZEej@dœdWdX„ZFej@dœdYdZ„ZGej@dœd[d\„ZHej@dœd]d^„ZIej@dœd_d`„ZJdeej@daœdbdc„ZKej@dœddde„ZLdŽeeejej
edfeejej
ej@fdfœdgdh„ZMejdœdidj„ZNejOdœdkdl„ZPej@ej@d9œdmdn„ZQej@ej@d9œdodp„ZRej@ejejSejTfd9œdqdr„ZUej@dœdsdt„ZVej
dœdudv„ZWej@ejXd9œdwdx„ZYdejej@eejej@dyœdzd{„ZZej@ej@d9œd|d}„Z[dejej
edfejejd~œdd€„Z\ej]dœdd‚„Z^dS)‘ÚParserz…This is the central parsing class Jinja uses.  It's passed to
    extensions and can be used to parse expressions or statements.
    Nr)ÚenvironmentÚsourceÚnameÚfilenameÚstateÚreturncCst||_|j||||ƒ|_||_||_d|_i|_x,|jƒD] }x|jD]}|j	|j|<qFWq:Wd|_
g|_g|_dS)NFr)
r!Ú	_tokenizeÚstreamr#r$ÚclosedÚ
extensionsZiter_extensionsÚtagsÚparseÚ_last_identifierÚ
_tag_stackÚ_end_token_stack)Úselfr!r"r#r$r%Ú	extensionÚtag©r3ú//tmp/pip-build-gk9425m9/Jinja2/jinja2/parser.pyÚ__init__3szParser.__init__zte.NoReturn)ÚmsgÚlinenoÚexcr&cCs(|dkr|jjj}||||j|jƒ‚dS)z Convenience method that raises `exc` with the message, passed
        line number or last line number as well as the current name and
        filename.
        N)r(Úcurrentr7r#r$)r0r6r7r8r3r3r4ÚfailJs

zParser.fail.)r#Úend_token_stackr7r&cCsÔtƒ}x|D]}|jtt|ƒƒqW|rDdjtttt|d
ƒƒƒ}nd}|dkrXdg}nd|›dg}|r |dk	rŽ||krŽ|jd|›dƒn|jd|›dƒ|jr¾|jd|jd›dƒ|jd	j|ƒ|ƒdS)Nz or rzUnexpected 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>)	rÚupdateÚmaprÚjoinÚreprÚappendr.r:)r0r#r;r7ÚexpectedÚexprsZcurrently_lookingÚmessager3r3r4Ú_fail_ut_eofXs(
zParser._fail_ut_eof)r#r7r&cCs|j||j|ƒdS)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)rGr/)r0r#r7r3r3r4Úfail_unknown_tag€szParser.fail_unknown_tag)Ú
end_tokensr7r&cCs.t|jƒ}|dk	r|j|ƒ|jd||ƒdS)z9Like fail_unknown_tag but for end of template situations.N)Úlistr/rCrG)r0rIr7Ústackr3r3r4Úfail_eof‰s

zParser.fail_eof)Úextra_end_rulesr&cCs,|jjjdkrdS|dk	r(|jjj|ƒSdS)zAre we at the end of a tuple?Úvariable_endÚ	block_endÚrparenTNF)rNrOrP)r(r9ÚtypeÚtest_any)r0rMr3r3r4Úis_tuple_end”s
zParser.is_tuple_end)r7r&cCs8|jd7_tjtjƒ}tjj|d|j›|d|S)zDReturn a new free identifier as :class:`~jinja2.nodes.InternalName`.rÚfi)r7)r-ÚobjectÚ__new__rÚInternalNameÚNoder5)r0r7Úrvr3r3r4Úfree_identifieržszParser.free_identifier)r&c
CsÒ|jj}|jdkr |jd|jƒ|jj|jƒd}zŠ|jtkrZt	|d|jjj›ƒ}|ƒS|jdkrl|j
ƒS|jdkr~|jƒS|jj
|jƒ}|dk	rœ||ƒS|jjƒd}|j|j|jƒWd|rÌ|jjƒXdS)	zParse a single statement.r#ztag name expectedTZparse_ÚcallÚfilterNF)r(r9rQr:r7r.rCÚvalueÚ_statement_keywordsÚgetattrÚparse_call_blockÚparse_filter_blockr*ÚgetÚpoprH)r0ÚtokenZpop_tagÚfÚextr3r3r4Úparse_statement¥s*




zParser.parse_statementF)rIÚdrop_needler&cCsL|jjdƒ|jjdƒ|j|ƒ}|jjjdkr:|j|ƒ|rHt|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.
        ÚcolonrOÚeof)r(Úskip_ifÚexpectÚsubparser9rQrLÚnext)r0rIrhÚresultr3r3r4Úparse_statementsÂs



zParser.parse_statementscCsft|jƒj}|jdd}|jjdƒr<|jƒ}tj|||dS|jdƒ}|j	ddd}tj
||||dS)	zParse an assign statement.T)Úwith_namespaceÚassign)r7Núname:endset)rh)rs)rnr(r7Úparse_assign_targetrkÚparse_tuplerÚAssignÚparse_filterrpÚAssignBlock)r0r7ÚtargetÚexprZfilter_nodeÚbodyr3r3r4Ú	parse_setßs
zParser.parse_setc	Csž|jjdƒj}|jdd}|jjdƒ|jddd}d}|jjdƒrL|jƒ}|jjdƒ}|jdƒ}t|jƒj	dkrxg}n|jddd
}t
j|||||||dS)zParse a for loop.zname:forúname:in)rMFúname:recursive)Ú
with_condexprrMNzname:ifúname:endforú	name:elseZendforT)rh)r7)r})r~)r€r)r€)r(rlr7rtrurkÚparse_expressionrprnr]rÚFor)r0r7ryÚiterÚtestÚ	recursiver{Úelse_r3r3r4Ú	parse_forês

zParser.parse_forcCsœtj|jjdƒjd}}x||jdd|_|jd
ƒ|_g|_	g|_
t|jƒ}|jdƒrxtj|jjjd}|j	j
|ƒqn|jdƒr’|jddd	|_
PqW|S)zParse an if construct.zname:if)r7F)rú	name:elifú	name:elseú
name:endifT)rh)r‰rŠr‹)r‹)rÚIfr(rlr7rur…rpr{Zelif_r‡rnr9rC)r0Únoderordr3r3r4Úparse_ifýs


zParser.parse_ifcCs–tjt|jƒjd}g}g}xX|jjjdkrt|r<|jjdƒ|jƒ}|j	dƒ|j
|ƒ|jjdƒ|j
|jƒƒqW||_||_
|jd	dd|_|S)
N)r7rOÚcommaÚparamrrúname:endwithT)rh)r‘)rÚWithrnr(r7r9rQrlrtÚset_ctxrCr‚ÚtargetsÚvaluesrpr{)r0rr”r•ryr3r3r4Ú
parse_withs

zParser.parse_withcCsDtjt|jƒjd}tjd|jƒƒg|_|jddd|_	tj
|gƒS)N)r7rúname:endautoescapeT)rh)r—)rZScopedEvalContextModifierrnr(r7ÚKeywordr‚Úoptionsrpr{ÚScope)r0rr3r3r4Úparse_autoescape szParser.parse_autoescapecCs¤tjt|jƒjd}|jjdƒj|_|jjdƒ|_	|jjdƒ|_
|jjjdkrX|j
dƒ|jddd	|_|j
rŽtd
d„|jDƒƒrŽ|j
dƒ|jjd
|jƒ|S)N)r7r#zname:scopedz
name:requiredrzpBlock names in Jinja have to be valid Python identifiers and may not contain hyphens, use an underscore instead.ú
name:endblockT)rhcss0|](}|jD]}t|tjƒo$|jjƒVqqdS)N)rÚ
isinstanceÚTemplateDataÚdataÚisspace)Ú.0r{Úchildr3r3r4ú	<genexpr>;sz%Parser.parse_block.<locals>.<genexpr>z7Required blocks can only contain comments or whitespacezname:)rœ)rÚBlockrnr(r7rlr]r#rkÚscopedÚrequiredr9rQr:rpr{Úall)r0rr3r3r4Úparse_block&s
zParser.parse_blockcCs"tjt|jƒjd}|jƒ|_|S)N)r7)rÚExtendsrnr(r7r‚Útemplate)r0rr3r3r4Ú
parse_extendsDs
zParser.parse_extends)rÚdefaultr&cCsH|jjjddƒr>|jjƒjdƒr>t|jƒjdk|_|jjƒn||_|S)Nz	name:withzname:withoutzname:contextr)	r(r9rRÚlookr…rnr]Úwith_contextÚskip)r0rr¬r3r3r4Úparse_import_contextIszParser.parse_import_contextcCsbtjt|jƒjd}|jƒ|_|jjjdƒrP|jj	ƒjdƒrPd|_
|jjdƒnd|_
|j|dƒS)N)r7zname:ignorezname:missingTéF)
rÚIncludernr(r7r‚rªr9r…r­Zignore_missingr¯r°)r0rr3r3r4Ú
parse_includeUs
zParser.parse_includecCsFtjt|jƒjd}|jƒ|_|jjdƒ|jddj	|_
|j|dƒS)N)r7zname:asT)Ú	name_onlyF)rÚImportrnr(r7r‚rªrlrtr#ryr°)r0rr3r3r4Úparse_importas

zParser.parse_importcstjtˆjƒjd‰ˆjƒˆ_ˆjjdƒgˆ_t	dœ‡‡fdd„}x¶ˆjrXˆjjdƒˆjj
jdkrì|ƒrnPˆjdd	}|j
jd
ƒr˜ˆjd|jtdˆjjd
ƒrƈjdd	}ˆjj|j
|j
fƒnˆjj|j
ƒ|ƒsèˆjj
jdkrøPqFˆjjdƒqFWtˆdƒsdˆ_ˆS)N)r7zname:import)r&csBˆjjjdkr>ˆjjƒjdƒr>tˆjƒjdkˆ_ˆjjƒdSdS)NrÚwithoutzname:contextTF>rr·)r(r9r]r­r…rnr®r¯r3)rr0r3r4Ú
parse_contextns
z(Parser.parse_from.<locals>.parse_contextrr#T)r´Ú_z4names starting with an underline can not be imported)r8zname:asr®F)rÚ
FromImportrnr(r7r‚rªrlÚnamesÚboolr9rQrtr#Ú
startswithr:rrkrCÚhasattrr®)r0r¸ryÚaliasr3)rr0r4Ú
parse_fromhs6
zParser.parse_from)rr&cCsžg}|_g}|_|jjdƒxl|jjjdkrŒ|r@|jjdƒ|jdd}|jdƒ|jjdƒrr|j	|j
ƒƒn|r€|jdƒ|j	|ƒq"W|jjdƒdS)	NÚlparenrPrT)r´rrrz-non-default argument follows default argument)ÚargsÚdefaultsr(rlr9rQrtr“rkrCr‚r:)r0rrÂrÃÚargr3r3r4Úparse_signature–s



zParser.parse_signaturecCsvtjt|jƒjd}|jjjdkr.|j|ƒng|_g|_	|j
ƒ}t|tjƒs\|j
d|jƒ||_|jddd|_|S)N)r7rÁz
expected callúname:endcallT)rh)rÆ)rÚ	CallBlockrnr(r7r9rQrÅrÂrÃr‚rÚCallr:r[rpr{)r0rZ	call_noder3r3r4r`¦szParser.parse_call_blockcCs8tjt|jƒjd}|jddd|_|jddd|_|S)N)r7T)Ústart_inlineúname:endfilter)rh)rÊ)	rÚFilterBlockrnr(r7rwr\rpr{)r0rr3r3r4raµszParser.parse_filter_blockcCsBtjt|jƒjd}|jddj|_|j|ƒ|jddd|_	|S)N)r7T)r´ú
name:endmacro)rh)rÌ)
rÚMacrornr(r7rtr#rÅrpr{)r0rr3r3r4Úparse_macro»s

zParser.parse_macrocCsTtjt|jƒjd}g|_x4|jjjdkrN|jr<|jjdƒ|jj|j	ƒƒqW|S)N)r7rOr)
rÚOutputrnr(r7r9rQrlrCr‚)r0rr3r3r4Úparse_printÂszParser.parse_printzte.Literal[True])Ú
with_tupler´r&cCsdS)Nr3)r0rÑr´r3r3r4rtËszParser.parse_assign_targetT)rÑr´rMrqr&cCsdS)Nr3)r0rÑr´rMrqr3r3r4rtÑscCsÄ|rN|jjƒjdkrN|jjdƒ}t|jƒ|jjdƒ}tj|j|j|jd}nL|rt|jjdƒ}tj	|jd|jd}n&|rˆ|j
d|d}n|jƒ}|jdƒ|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#)r7ÚstoreT)Ú
simplifiedrMzcan't assign to )r(r­rQrlrnrÚNSRefr]r7ÚNameruÚ
parse_primaryr“Z
can_assignr:Ú__name__Úlower)r0rÑr´rMrqrdÚattrryr3r3r4rtÛs"

)rr&cCs|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)r0rr3r3r4r‚szParser.parse_expressioncCsf|jjj}|jƒ}xN|jjdƒr`|jƒ}|jjdƒr>|jƒ}nd}tj||||d}|jjj}qW|S)Nzname:ifz	name:else)r7)r(r9r7rÜrkrÛrZCondExpr)r0r7Zexpr1Zexpr2Zexpr3r3r3r4rÛs

zParser.parse_condexprcCsJ|jjj}|jƒ}x2|jjdƒrD|jƒ}tj|||d}|jjj}qW|S)Nzname:or)r7)r(r9r7Ú	parse_andrkrÚOr)r0r7ÚleftÚrightr3r3r4rÜs
zParser.parse_orcCsJ|jjj}|jƒ}x2|jjdƒrD|jƒ}tj|||d}|jjj}qW|S)Nzname:and)r7)r(r9r7Ú	parse_notrkrÚAnd)r0r7rßràr3r3r4rÝ&s
zParser.parse_andcCs4|jjjdƒr,t|jƒj}tj|jƒ|dS|jƒS)Nzname:not)r7)	r(r9r…rnr7rÚNotráÚ
parse_compare)r0r7r3r3r4rá/szParser.parse_notcCsÚ|jjj}|jƒ}g}xª|jjj}|tkrLt|jƒ|jtj	||jƒƒƒnh|jj
dƒrp|jtj	d|jƒƒƒnD|jjjdƒr²|jjƒjdƒr²|jj
dƒ|jtj	d|jƒƒƒnP|jjj}qW|sÊ|Stj|||dS)Nzname:inÚinzname:notr±Únotin)r7)r(r9r7Úparse_math1rQÚ_compare_operatorsrnrCrZOperandrkr…r­r¯ÚCompare)r0r7rzÚopsÚ
token_typer3r3r4rä5s&


zParser.parse_comparecCsb|jjj}|jƒ}xJ|jjjdkr\t|jjj}t|jƒ|jƒ}||||d}|jjj}qW|S)Nrr)r7)rr)r(r9r7Úparse_concatrQÚ_math_nodesrn)r0r7rßÚclsràr3r3r4rçLs

zParser.parse_math1cCsb|jjj}|jƒg}x*|jjjdkr>t|jƒ|j|jƒƒqWt|ƒdkrT|dStj	||dS)NÚtilderr)r7)
r(r9r7Úparse_math2rQrnrCÚlenrZConcat)r0r7rÂr3r3r4rìWs


zParser.parse_concatcCsb|jjj}|jƒ}xJ|jjjdkr\t|jjj}t|jƒ|jƒ}||||d}|jjj}qW|S)Nrrrr)r7)rrrr)r(r9r7Ú	parse_powrQrírn)r0r7rßrîràr3r3r4rðas

zParser.parse_math2cCsV|jjj}|jƒ}x>|jjjdkrPt|jƒ|jƒ}tj|||d}|jjj}qW|S)NÚpow)r7)r(r9r7Úparse_unaryrQrnrÚPow)r0r7rßràr3r3r4ròls

zParser.parse_pow)Úwith_filterr&cCsˆ|jjj}|jjj}|dkr<t|jƒtj|jdƒ|d}n0|dkrdt|jƒtj|jdƒ|d}n|j	ƒ}|j
|ƒ}|r„|j|ƒ}|S)NrF)r7r)r(r9rQr7rnrZNegrôZPosr×Ú
parse_postfixÚparse_filter_expr)r0rörër7rr3r3r4rôvs





zParser.parse_unarycCsz|jj}|jdkrr|jdkr4tj|jdk|jd}n0|jdkrPtjd|jd}ntj|jd	|jd}t|jƒn|jd
krØt|jƒ|jg}|j}x,|jjjd
krÀ|j	|jjjƒt|jƒq–Wtjdj
|ƒ|d}nž|jdkrt|jƒtj|j|jd}nt|jdkr2t|jƒ|jdd}|jjdƒnD|jdkrH|j
ƒ}n.|jdkr^|jƒ}n|jdt|ƒ›|jƒ|S)Nr#ÚtrueÚfalseÚTrueÚFalse)r7ÚnoneÚNoneÚloadÚstringÚÚintegerÚfloatrÁT)Úexplicit_parenthesesrPÚlbracketÚlbracezunexpected )rùrúrûrü)rùrû)rýrþ)rr)r(r9rQr]rÚConstr7rÖrnrCrArurlÚ
parse_listÚ
parse_dictr:r)r0rdrÚbufr7r3r3r4r׈s:








zParser.parse_primary)rÔrrMrr&c	sȈjjj}|rˆj}n |r"ˆj}ntjdœ‡fdd„}g}d}xL|rPˆjjdƒˆj|ƒr\P|j	|ƒƒˆjjj
dkr|d}nPˆjjj}q@W|s¸|rœ|dS|s¸ˆjdtˆjjƒ›ƒtj
|d	|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&csˆjddS)NF)r)r‚r3)r0r3r4r,Êsz!Parser.parse_tuple.<locals>.parseFrTrzExpected an expression, got rÿ)r7)r(r9r7r×r‚rÚExprrlrSrCrQr:rÚTuple)	r0rÔrrMrr7r,rÂZis_tupler3)r0r4ruªs2

zParser.parse_tuplecCsn|jjdƒ}g}x@|jjjdkrP|r0|jjdƒ|jjjdkr@P|j|jƒƒqW|jjdƒtj||jdS)NrÚrbracketr)r7)	r(rlr9rQrCr‚rÚListr7)r0rdÚitemsr3r3r4rìszParser.parse_listcCs”|jjdƒ}g}xf|jjjdkrv|r0|jjdƒ|jjjdkr@P|jƒ}|jjdƒ|jƒ}|jtj|||jdƒqW|jjdƒtj	||jdS)NrZrbracerri)r7)
r(rlr9rQr‚rCrZPairr7ÚDict)r0rdrÚkeyr]r3r3r4r	øszParser.parse_dictcCsFx@|jjj}|dks|dkr(|j|ƒ}q|dkr<|j|ƒ}qPqW|S)NrÒrrÁ)r(r9rQÚparse_subscriptÚ
parse_call)r0rrër3r3r4r÷s
zParser.parse_postfixcCs`xZ|jjj}|dkr |j|ƒ}q|dkrB|jjjdkrB|j|ƒ}q|dkrV|j|ƒ}qPqW|S)NÚpiper#ÚisrÁ)r(r9rQrwr]Ú
parse_testr)r0rrër3r3r4røs
zParser.parse_filter_exprcCs t|jƒ}|jdkr„|jj}t|jƒ|jdkrFtj||jd|jdS|jdkr^|jd|jƒtj	|j|jd}tj
||d|jdS|jdkrg}x0|jjjdkrÄ|r´|jjd	ƒ|j|j
ƒƒq–W|jjdƒt|ƒd
krè|d}ntj|d|jd}tj
||d|jdS|jd|jƒdS)
NrÒr#rÿ)r7rzexpected name or numberrr
rrrzexpected subscript expression)rnr(rQr9rÚGetattrr]r7r:rÚGetitemrlrCÚparse_subscribedrñr)r0rrdZ
attr_tokenrÄrÂr3r3r4r#s.





zParser.parse_subscriptcCsò|jjj}|jjjdkr*t|jƒdg}n*|jƒ}|jjjdkrD|St|jƒ|g}|jjjdkrn|jdƒn(|jjjdkrŒ|j|jƒƒn
|jdƒ|jjjdkrØt|jƒ|jjjdkrÌ|j|jƒƒqâ|jdƒn
|jdƒtj|d|iŽS)Nrir
rr7)r
r)r
r)	r(r9r7rQrnr‚rCrÚSlice)r0r7rÂrr3r3r4rBs*





zParser.parse_subscribedc	s~ˆjjdƒ‰g}g}d}d}d}tddœ‡‡fdd„}x,ˆjjjdkrd|rjˆjjdƒˆjjjdkrjPˆjjjdkr ||dkoˆ|dkƒtˆjƒˆjƒ}n¾ˆjjjd	krÎ||dkƒtˆjƒˆjƒ}nˆjjjd
koêˆjjƒjdkr2||dkƒˆjjj}ˆjj	dƒˆjƒ}|j
tj|||j
d
ƒn,||dkoL|dkoL|ƒ|j
ˆjƒƒd}q:Wˆjjdƒ||||fS)NrÁF)rzr&cs|sˆjdˆjƒdS)Nz+invalid syntax for function call expression)r:r7)rz)r0rdr3r4Úensurejsz&Parser.parse_call_args.<locals>.ensurerPrrrór#rrr±)r7T)r(rlr¼r9rQrnr‚r­r]r¯rCrr˜r7)	r0rÂÚkwargsÚdyn_argsÚ
dyn_kwargsZ
require_commarrr]r3)r0rdr4Úparse_call_argsbs@




zParser.parse_call_argscCs0|jj}|jƒ\}}}}tj||||||jdS)N)r7)r(r9rrrÈr7)r0rrdrÂrrrr3r3r4r“szParser.parse_call)rrÉr&c		Cs¾x¸|jjjdks|r¸|s"t|jƒ|jjdƒ}|j}x2|jjjdkrft|jƒ|d|jjdƒj7}q6W|jjjdkrˆ|jƒ\}}}}ng}g}d}}tj|||||||j	d}d}qW|S)Nrr#rÒr<rÁ)r7F)
r(r9rQrnrlr]rrÚFilterr7)	r0rrÉrdr#rÂrrrr3r3r4rwšs"

zParser.parse_filterc
	Cs&t|jƒ}|jjjdƒr(t|jƒd}nd}|jjdƒj}x2|jjjdkrlt|jƒ|d|jjdƒj7}q<Wd}}g}|jjjdkrš|jƒ\}}}}nX|jjjdkrî|jjjd
ddƒrî|jjjdƒrÔ|j	dƒ|j
ƒ}	|j|	ƒ}	|	g}ng}tj
|||||||jd}|r"tj||jd}|S)Nzname:notTFr#rÒr<rÁrrrrrz	name:elsezname:orzname:andzname:isz'You cannot chain multiple tests with is)r7>rrÁrrr#rr)rnr(r9r…rlr]rQrrRr:r×r÷rZTestr7rã)
r0rrdZnegatedr#rrrrÂZarg_noder3r3r4r±sB




zParser.parse_test)rIr&csLg‰g‰ˆj}|dk	r"|jj|ƒddœ‡‡fdd„}zúxî|jr&|jj}|jdkr||jrp|tj|j|jdƒt	|jƒq:|jdkr®t	|jƒ||j
ddƒ|jjd	ƒq:|jd
kr|ƒt	|jƒ|dk	rä|jjj|ŽräˆS|j
ƒ}t|tƒrˆj|ƒn
ˆj|ƒ|jjdƒq:tdƒ‚q:W|ƒWd|dk	rF|jjƒXˆS)
N)r&cs8ˆr4ˆdj}ˆjtjˆdd…|dƒˆdd…=dS)Nr)r7)r7rCrrÏ)r7)r{Údata_bufferr3r4Ú
flush_dataås
z#Parser.subparse.<locals>.flush_datarŸ)r7Zvariable_beginT)rrNZblock_beginrOzinternal parsing error)rCr/r(r9rQr]rržr7rnrurlrRrgrrJÚextendÚAssertionErrorrc)r0rIZadd_datar"rdrYr3)r{r!r4rmÛsB







zParser.subparsecCs"tj|jƒdd}|j|jƒ|S)z0Parse the whole template into a `Template` node.r)r7)rÚTemplatermZset_environmentr!)r0ror3r3r4r,szParser.parse)NNN)N)NN)N)N)F)..)TFNF)TFNF)T)T)FTNF)F)N)_rØÚ
__module__Ú__qualname__Ú__doc__ÚstrÚtÚOptionalr5rÚintÚTyper:rrrGrHrLr¼rSrrWrZÚUnionrXrgrprvrxr|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ËrarÍrÎrÏrÐÚtypingZoverloadrÖrtrÕrr‚rÛrÜrÝrárärçrìrðròrôr×rurrr	r÷rørrrrrrÈrrwrrmr%r,r3r3r3r4r .s¬$	"
.	" $			

$<
 1+/r )&r(r/r*rrÚ
exceptionsrrÚlexerrrZ
TYPE_CHECKINGZtyping_extensionsÚter!rZTypeVarrµr²r	rÍrÇr
Ú	frozensetr^rèÚAddÚSubZMulÚDivÚFloorDivÚModrírr)r-rr r3r3r3r4Ú<module>sB