+
    کh?                         ^ RI HtHt ^ RIHtHtHtHt ^ RIH	t	 R R lt
 ! R R4      t ! R R	]4      t ! R
 R]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      tR# )    )abstractmethodabstractproperty)ListOptionalTupleUnion)split_linesc                ,    V ^8  d   QhRRR\         RR/# )   node
NodeOrLeaf
node_typesreturnOptional[BaseNode]str)formats   ",/usr/lib/python3/dist-packages/parso/tree.py__annotate__r      s"      , S =Q     c                h    V P                   pVe"   VP                  V9   d   V# VP                   pK%  R# )aV  
Recursively looks at the parents of a node and returns the first found node
that matches ``node_types``. Returns ``None`` if no matching node is found.

This function is deprecated, use :meth:`NodeOrLeaf.search_ancestor` instead.

:param node: The ancestors of this node will be checked.
:param node_types: type names that are searched for.
Nparenttype)r   r   ns   &* r   search_ancestorr      s/     	A
-66ZHHHr   c                      a  ] tR t^t o RtRt  R tR tR tR t	R t
]V 3R lR l4       t]V 3R	 lR
 l4       t]R 4       t]R 4       t]R 4       t]RR l4       tV 3R lR ltR^/V 3R lR lltV 3R ltRtV tR# )r   z&
The base class for nodes and leaves.
c                B    T pVP                   e   VP                   pK  V# )zw
Returns the root node of a parser tree. The returned node doesn't have
a parent node like all the other nodes/leaves.
r   )selfscopes   & r   get_root_nodeNodeOrLeaf.get_root_node(   s!    
 ll&LLEr   c                    V P                   pVf   R# \        VP                  4       F1  w  r#W0J g   K   V P                   P                  V^,           ,          u # 	  R#   \         d      R# i ; i)z
Returns the node immediately following this node in this parent's
children list. If this node does not have a next sibling, it is None
N)r   	enumeratechildren
IndexErrorr    r   ichilds   &   r   get_next_siblingNodeOrLeaf.get_next_sibling2   sc    
 > "&//2HA} ;;//A66 3 "   s   #AA/.A/c                    V P                   pVf   R# \        VP                  4       F:  w  r#W0J g   K  V^ 8X  d    R# V P                   P                  V^,
          ,          u # 	  R# )z
Returns the node immediately preceding this node in this parent's
children list. If this node does not have a previous sibling, it is
None.
N)r   r%   r&   r(   s   &   r   get_previous_siblingNodeOrLeaf.get_previous_siblingC   sT     > "&//2HA}6{{++AE22	 3r   c                4   V P                   f   R# T p VP                   P                  pVP                  V4      pV^ 8X  d   VP                   pVP                   f   R# KM  W#^,
          ,          p   TP                  R,          pK    \         d    Tu # i ; i)zo
Returns the previous leaf in the parser tree.
Returns `None` if this is the first element in the parser tree.
N)r   r&   indexAttributeErrorr    r   cr)   s   &   r   get_previous_leafNodeOrLeaf.get_previous_leafT   s    
 ;;$$AAAv{{;;& ' Qx}}R(! s   2B BBc                T   V P                   f   R# T p VP                   P                  pVP                  V4      pV\        V4      ^,
          8X  d   VP                   pVP                   f   R# K]  W#^,           ,          p   TP                  ^ ,          pK    \         d    Tu # i ; i)zh
Returns the next leaf in the parser tree.
Returns None if this is the last element in the parser tree.
N)r   r&   r2   lenr3   r4   s   &   r   get_next_leafNodeOrLeaf.get_next_leafn   s    
 ;;$$AACFQJ{{;;& ' Qx}}Q'! s   B B'&B'c                6   < V ^8  d   QhRS[ S[S[3,          /# r   r   r   int)r   __classdict__s   "r   r   NodeOrLeaf.__annotate__   s      5c? r   c                    R# )zn
Returns the starting position of the prefix as a tuple, e.g. `(3, 4)`.

:return tuple of int: (line, column)
N r    s   &r   	start_posNodeOrLeaf.start_pos       r   c                6   < V ^8  d   QhRS[ S[S[3,          /# r=   r>   )r   r@   s   "r   r   rA      s      sCx r   c                    R# )zi
Returns the end position of the prefix as a tuple, e.g. `(3, 4)`.

:return tuple of int: (line, column)
NrC   rD   s   &r   end_posNodeOrLeaf.end_pos   rG   r   c                    R# )z
Returns the start_pos of the prefix. This means basically it returns
the end_pos of the last prefix. The `get_start_pos_of_prefix()` of the
prefix `+` in `2 + 1` would be `(1, 1)`, while the start_pos is
`(1, 2)`.

:return tuple of int: (line, column)
NrC   rD   s   &r   get_start_pos_of_prefix"NodeOrLeaf.get_start_pos_of_prefix   rG   r   c                    R# )z?
Returns the first leaf of a node or itself if this is a leaf.
NrC   rD   s   &r   get_first_leafNodeOrLeaf.get_first_leaf   rG   r   c                    R# )z>
Returns the last leaf of a node or itself if this is a leaf.
NrC   rD   s   &r   get_last_leafNodeOrLeaf.get_last_leaf   rG   r   c                    R# )z
Returns the code that was the input for the parser for this node.

:param include_prefix: Removes the prefix (whitespace and comments) of
    e.g. a statement.
NrC   r    include_prefixs   &&r   get_codeNodeOrLeaf.get_code   rG   r   c                $   < V ^8  d   QhRS[ RR/# )r   r   r   r   r   )r   r@   s   "r   r   rA      s      3 3G r   c                h    V P                   pVe"   VP                  V9   d   V# VP                   pK%  R# )z
Recursively looks at the parents of this node or leaf and returns the
first found node that matches ``node_types``. Returns ``None`` if no
matching node is found.

:param node_types: type names that are searched for.
Nr   )r    r   r   s   &* r   r   NodeOrLeaf.search_ancestor   s0     {{yyJ&;;Dr   indentc                L   < V ^8  d   QhRS[ S[S[S[3,          ,          RS[/# )r   r]   r   )r   r   r?   r   )r   r@   s   "r   r   rA      s,     V" V"huS#X7 V" V"r   c                  aaa Vf   RoRoML\        V\        4      '       d   RoRV,          oM*\        V\        4      '       d   RoVoM\        RV: 24      hRR VVV3R llloS! V 4      # )	a  
Returns a formatted dump of the parser tree rooted at this node or leaf. This is
mainly useful for debugging purposes.

The ``indent`` parameter is interpreted in a similar way as :py:func:`ast.dump`.
If ``indent`` is a non-negative integer or string, then the tree will be
pretty-printed with that indent level. An indent level of 0, negative, or ``""``
will only insert newlines. ``None`` selects the single line representation.
Using a positive integer indent indents that many spaces per level. If
``indent`` is a string (such as ``"\t"``), that string is used to indent each
level.

:param indent: Indentation style as described above. The default indentation is
    4 spaces, which yields a pretty-printed dump.

>>> import parso
>>> print(parso.parse("lambda x, y: x + y").dump())
Module([
    Lambda([
        Keyword('lambda', (1, 0)),
        Param([
            Name('x', (1, 7), prefix=' '),
            Operator(',', (1, 8)),
        ]),
        Param([
            Name('y', (1, 10), prefix=' '),
        ]),
        Operator(':', (1, 11)),
        PythonNode('arith_expr', [
            Name('x', (1, 13), prefix=' '),
            Operator('+', (1, 15), prefix=' '),
            Name('y', (1, 17), prefix=' '),
        ]),
    ]),
    EndMarker('', (1, 18)),
])
F T z,expect 'indent' to be int, str or None, got c                H    V ^8  d   QhR\         R\        R\        R\        /# )r   r   r]   	top_levelr   )r   r   bool)r   s   "r   r   %NodeOrLeaf.dump.<locals>.__annotate__   s)     "	 "	z "	3 "	 "	X[ "	r   c                   < R p\        V 4      P                  p\        V \        4      '       d   W1 V R2,          p\        V \        4      '       d   W0P
                  : R2,          pM,\        V \        4      '       d   W0P                   : R2,          pW0P                  : RV P                  : 2,          pV P                  '       d   VRV P                  : 2,          pVR,          pM\        V \        4      '       d   W1 V R2,          p\        V \        4      '       d   W0P                   : R2,          pVR,          pS'       d
   VR,          pV P                   F  pVS! WQS,           RR7      ,          pK  	  W1 R	2,          pM\        R
V : 24      hV'       g   S'       d   VR,          pV# VR,          pV# )r`   (, z	, prefix=)[
F)r]   rc   z])zunsupported node encountered: z,
)r   __name__
isinstanceLeaf	ErrorLeaf
token_type	TypedLeafvaluerE   prefixBaseNodeNoder&   	TypeError)	r   r]   rc   result	node_typer*   _format_dumpindent_stringnewlines	   &&&   r   ry   %NodeOrLeaf.dump.<locals>._format_dump   s~   FT
++I$%%HYKq11dI.. 3266Fi00R00FZZN"T^^,>??;;;	$++99F#D(++HYKq11dD))R00F#dNF!]]El5-9O[`aaF +HB-'  "@ IJJeOF M dNFMr   )r`   T)rm   r?   r   rv   )r    r]   ry   rz   r{   s   &$@@@r   dumpNodeOrLeaf.dump   sr    L >GM$$G&LM$$G"MJ6*UVV"	 "	H D!!r   c                0   < V ^8  d   Qh/ S[ ;R&   R;R&   # )r   r   r   r   r   )r   r@   s   "r   r   rA      s     
 I  !  r   rC   Nr   T)rl   
__module____qualname____firstlineno____doc__	__slots__r"   r+   r.   r6   r:   r   rE   rJ   r   rM   rP   rS   rX   r   r}   __annotate_func____static_attributes____classdictcell__r@   s   @r   r   r      s      I
 "3"44        
  
   V"! V" V"]  r   r   c                      a  ] tR tRt o RtRtRV 3R lR llt]V 3R lR l4       t]P                  V 3R lR l4       tR	 t
R
 tR tRR lt]V 3R lR l4       tR tV 3R ltRtV tR# )rn   i   zw
Leafs are basically tokens with a better API. Leafs exactly know where they
were defined and what text preceeds them.
c                F   < V ^8  d   QhRS[ RS[S[S[3,          RS[ RR/# )r   rr   rE   rs   r   N)r   r   r?   )r   r@   s   "r   r   Leaf.__annotate__(  s2      c eCHo s TX r   c                <    Wn          W n        W0n         R V n        R # N)rr   rE   rs   r   )r    rr   rE   rs   s   &&&&r   __init__Leaf.__init__(  s+    
	 #	 +/	r   c                6   < V ^8  d   QhRS[ S[S[3,          /# r=   r>   )r   r@   s   "r   r   r   9  s     & &5c? &r   c                2    V P                   V P                  3# r   linecolumnrD   s   &r   rE   Leaf.start_pos8  s    yy$++%%r   c                :   < V ^8  d   QhRS[ S[S[3,          RR/# )r   rr   r   Nr>   )r   r@   s   "r   r   r   =  s#      uS#X 4 r   c                >    V^ ,          V n         V^,          V n        R# )r   Nr   r    rr   s   &&r   rE   r   <  s    !H	Ahr   c                    V P                  4       pVf;   \        V P                  4      pV P                  \	        V4      ,
          ^,           ^ 3# VP
                  # r   )r6   r	   rs   r   r9   rJ   )r    previous_leafliness   &  r   rM   Leaf.get_start_pos_of_prefixA  sM    ..0 ,E99s5z)A-q00$$$r   c                    V # r   rC   rD   s   &r   rP   Leaf.get_first_leafI      r   c                    V # r   rC   rD   s   &r   rS   Leaf.get_last_leafL  r   r   c                d    V'       d   V P                   V P                  ,           # V P                  # r   )rs   rr   rV   s   &&r   rX   Leaf.get_codeO  s"    ;;++::r   c                6   < V ^8  d   QhRS[ S[S[3,          /# r=   r>   )r   r@   s   "r   r   r   V  s     , ,sCx ,r   c                
   \        V P                  4      pV P                  \        V4      ,           ^,
          pV P                  V8X  d'   V P                  \        VR,          4      ,           pW#3# \        VR,          4      pW#3#    r1   )r	   rr   r   r9   r   )r    r   end_pos_lineend_pos_columns   &   r   rJ   Leaf.end_posU  sl    DJJ'yy3u:-199$![[3uRy>9N ++ !r^N++r   c                ~    V P                   pV'       g   V P                  pR \        V 4      P                  : RV: R2# )<: >)rr   r   rl   r   s   & r   __repr__Leaf.__repr__`  s-    

IIE!$Z00%88r   c                &   < V ^8  d   Qh/ S[ ;R&   # )r   rs   r   )r   r@   s   "r   r   r      s      K r   )r   r   r   rs   rE   rr   N)rr   r   r   rs   r`   r   )rl   r   r   r   r   r   r   propertyrE   setterrM   rP   rS   rX   rJ   r   r   r   r   r   s   @r   rn   rn      s~      6I   & &  % , ,9A  r   rn   c                   :   a a ] tR tRt oRtRV 3R lltRtVtV ;t# )rq   ig  c                4   < \         SV `  W#V4       Wn        R # r   superr   r   )r    r   rr   rE   rs   	__class__s   &&&&&r   r   TypedLeaf.__init__j  s    62	r   r   r   )	rl   r   r   r   r   r   r   r   __classcell__r   r@   s   @@r   rq   rq   g  s     I r   rq   c                      a  ] tR tRt o RtRtV 3R lR lt]V 3R lR l4       tR t	]V 3R lR	 l4       t
R
 tRR ltRR ltR tR tR tRtV tR# )rt   io  zX
The super class for all nodes.
A node has children, a type and possibly a parent node.
c                4   < V ^8  d   QhRS[ S[,          RR/# )r   r&   r   N)r   r   )r   r@   s   "r   r   BaseNode.__annotate__v  s         j!1  d  r   c                B    Wn          R V n         V F	  pWn        K  	  R # r   r&   r   )r    r&   r*   s   && r   r   BaseNode.__init__v  s+     	 +/	 EL r   c                6   < V ^8  d   QhRS[ S[S[3,          /# r=   r>   )r   r@   s   "r   r   r     s     * *5c? *r   c                <    V P                   ^ ,          P                  # r   )r&   rE   rD   s   &r   rE   BaseNode.start_pos  s    }}Q)))r   c                D    V P                   ^ ,          P                  4       # r   )r&   rM   rD   s   &r   rM    BaseNode.get_start_pos_of_prefix  s    }}Q7799r   c                6   < V ^8  d   QhRS[ S[S[3,          /# r=   r>   )r   r@   s   "r   r   r     s     ) )sCx )r   c                <    V P                   R,          P                  # r   )r&   rJ   rD   s   &r   rJ   BaseNode.end_pos  s    }}R (((r   c                    V'       d   R P                  R V 4       4      # V^ ,          P                  RR7      pVR P                  R VR,           4       4      ,           # )r`   c              3   @   "   T F  qP                  4       x  K  	  R # 5ir   rX   .0r5   s   & r   	<genexpr>2BaseNode._get_code_for_children.<locals>.<genexpr>  s     :A::<<   F)rW   c              3   @   "   T F  qP                  4       x  K  	  R # 5ir   r   r   s   & r   r   r     s     "FA::<<r   :r   NN)joinrX   )r    r&   rW   firsts   &&& r   _get_code_for_childrenBaseNode._get_code_for_children  sO    77::::QK(((>E277"F""FFFFr   c                :    V P                  V P                  V4      # r   )r   r&   rV   s   &&r   rX   BaseNode.get_code  s    **4==.IIr   c                   a aaa VVVV 3R loRSu;8:  d#   S P                   R,          P                  8:  g   M \        R4      hS! ^ \        S P                   4      ^,
          4      # )aH  
Get the :py:class:`parso.tree.Leaf` at ``position``

:param tuple position: A position tuple, row, column. Rows start from 1
:param bool include_prefixes: If ``False``, ``None`` will be returned if ``position`` falls
    on whitespace or comments before a leaf
:return: :py:class:`parso.tree.Leaf` at ``position``, or ``None``
c                 `  < W8X  dB   SP                   V ,          pS'       g   SVP                  8  d   R #  VP                  SS4      # \	        W,           ^,          4      pSP                   V,          pSVP
                  8:  d	   S! W4      # S! V^,           V4      #   \         d    Tu # i ; ir   )r&   rE   get_leaf_for_positionr3   r?   rJ   )lowerupperelementr2   binary_searchinclude_prefixespositionr    s   &&  r   r   5BaseNode.get_leaf_for_position.<locals>.binary_search  s    ~--.'Hw7H7H,H#"88CSTT !+,EmmE*G7??*$U22$UQY66 & #"N#s   B B-,B-z7Please provide a position that exists within this node.)r   r   r1   )r&   rJ   
ValueErrorr9   )r    r   r   r   s   fff@r   r   BaseNode.get_leaf_for_position  sR    	7 	7& (?dmmB&7&?&??VWWQDMM 2Q 677r   c                D    V P                   ^ ,          P                  4       # r   )r&   rP   rD   s   &r   rP   BaseNode.get_first_leaf  s    }}Q..00r   c                D    V P                   R,          P                  4       # r   )r&   rS   rD   s   &r   rS   BaseNode.get_last_leaf  s    }}R ..00r   c           	        V P                  4       P                  R R4      P                  RR4      P                  4       pR\        V 4      P                  : RV: RV P
                  ^ ,          : RV P
                  ^,          : R2	# )rk   ra   r   r   @,r   )rX   replacestripr   rl   rE   )r    codes   & r   r   BaseNode.__repr__  sg    }}&&tS199$DJJL$Z  $q(9(94>>!;L;LN 	Nr   r   N)r&   r   )F)rl   r   r   r   r   r   r   r   rE   rM   rJ   r   rX   r   rP   rS   r   r   r   r   s   @r   rt   rt   o  sp      I    * *: ) )GJ8@11N Nr   rt   c                   @   a a ] tR tRt oRtRtV 3R ltR tRtVt	V ;t
# )ru   i  z+Concrete implementation for interior nodes.c                2   < \         SV `  V4       Wn        R # r   r   )r    r   r&   r   s   &&&r   r   Node.__init__  s    "	r   c                n    V P                   P                  : R V P                  : RV P                  : R2# )rg   rh   ri   )r   rl   r   r&   rD   s   &r   r   Node.__repr__  s!    #~~66		4==QQr   r   )rl   r   r   r   r   r   r   r   r   r   r   r   s   @@r   ru   ru     s     5IR Rr   ru   c                   "    ] tR tRtRtRtRtRtR# )	ErrorNodei  z
A node that contains valid nodes/leaves that we're follow by a token that
was invalid. This basically means that the leaf after this node is where
Python would mark a syntax error.

error_noderC   N)rl   r   r   r   r   r   r   r   rC   r   r   r   r     s    
 IDr   r   c                   H   a a ] tR tRt oRtRtRtRV 3R lltR tRt	Vt
V ;t# )ro   i  z
A leaf that is either completely invalid in a language (like `$` in Python)
or is invalid at that position. Like the star in `1 +* 1`.

error_leafc                4   < \         SV `  W#V4       Wn        R # r   )r   r   rp   )r    rp   rr   rE   rs   r   s   &&&&&r   r   ErrorLeaf.__init__  s    62$r   c           	         R \        V 4      P                  : RV P                  : R\        V P                  4      : RV P
                  : R2	# )r   r   :rh   r   )r   rl   rp   reprrr   rE   rD   s   &r   r   ErrorLeaf.__repr__  s2    $Z  $//4

3CT^^U 	Ur   )rp   r   )rl   r   r   r   r   r   r   r   r   r   r   r   r   s   @@r   ro   ro     s'       ID%U Ur   ro   N)abcr   r   typingr   r   r   r   parso.utilsr	   r   r   rn   rq   rt   ru   r   ro   rC   r   r   <module>r     sw    0 / / #$D" D"ND9: D9N RNz RNj	R8 	R U Ur   