+
    کh                         R t ^ RIHtHt ^ RIHt ^ RIHt  ! R R]4      t	 ! R R]4      t
 ! R R	]4      t ! R
 R4      tR t ! R R4      tR# )a  
The ``Parser`` tries to convert the available Python code in an easy to read
format, something like an abstract syntax tree. The classes who represent this
tree, are sitting in the :mod:`parso.tree` module.

The Python module ``tokenize`` is a very important part in the ``Parser``,
because it splits the code into different words (tokens).  Sometimes it looks a
bit messy. Sorry for that! You might ask now: "Why didn't you use the ``ast``
module for this? Well, ``ast`` does a very good job understanding proper Python
code, but fails to work as soon as there's a single line of broken code.

There's one important optimization that needs to be known: Statements are not
being parsed completely. ``Statement`` is just a representation of the tokens
within the statement. This lowers memory usage and cpu time and reduces the
complexity of the ``Parser`` (there's another parser sitting inside
``Statement``, which produces ``Array`` and ``Call``).
)DictType)tree)ReservedStringc                   *   a  ] tR t^ t o RtR tRtV tR# )ParserSyntaxErrorzS
Contains error information about the parser tree.

May be raised as an exception.
c                    Wn         W n        R # N)message
error_leaf)selfr
   r   s   &&&./usr/lib/python3/dist-packages/parso/parser.py__init__ParserSyntaxError.__init__&   s    $    )r   r
   N__name__
__module____qualname____firstlineno____doc__r   __static_attributes____classdictcell____classdict__s   @r   r   r       s     
% %r   r   c                   *   a  ] tR t^+t o RtR tRtV tR# )InternalParseErrorz
Exception to signal the parser is stuck and error recovery didn't help.
Basically this shouldn't happen. It's a sign that something is really
wrong.
c           
         \         P                  V V: R VP                  : RV: RV: 24       Wn        \        V n        W0n        W@n        R# )z: type=z, value=z, start_pos=N)	Exceptionr   namemsgtypevalue	start_pos)r   r    type_r"   r#   s   &&&&&r   r   InternalParseError.__init__2   s;    4UI"? 	@	
"r   )r    r#   r!   r"   Nr   r   s   @r   r   r   +   s     # #r   r   c                   &   a  ] tR t^;t o R tRtV tR# )Stackc                0   a  V 3R  lp\        V! 4       4      # )c               3      <"   \        S4       Fi  p V P                  P                   F-  p\        V\        4      '       d   VP
                  x  K)  Vx  K/  	  V P                  P                  '       d   Kh   R # 	  R # 5ir	   )reverseddfatransitions
isinstancer   r"   is_final)
stack_node
transitionr   s     r   iterate@Stack._allowed_transition_names_and_token_types.<locals>.iterate=   s\     &tn
",.."<"<J!*n==(...((	 #= "~~... -s   A/A>7A>)list)r   r1   s   f r   )_allowed_transition_names_and_token_types/Stack._allowed_transition_names_and_token_types<   s    
	 GIr    N)r   r   r   r   r4   r   r   r   s   @r   r'   r'   ;   s      r   r'   c                   <   a  ] tR t^Lt o R t]R 4       tR tRtV t	R# )	StackNodec                     Wn         . V n        R # r	   r+   nodes)r   r+   s   &&r   r   StackNode.__init__M   s    
r   c                .    V P                   P                  # r	   )r+   	from_ruler   s   &r   nonterminalStackNode.nonterminalQ   s    xx!!!r   c                n    V P                   P                  : R V P                  : RV P                  : R2# )(z, ))	__class__r   r+   r;   r?   s   &r   __repr__StackNode.__repr__U   s!    #~~66$**MMr   r:   N)
r   r   r   r   r   propertyr@   rF   r   r   r   s   @r   r8   r8   L   s*      " "N Nr   r8   c                     VP                   P                  '       d    V P                  V,          # V#   \         d     T# i ; ir	   )r"   contains_syntaxreserved_syntax_stringsKeyError)grammarr$   r"   s   &&&r   _token_to_transitionrN   Y   sH    {{"""	22599 L  	L	s   3 AAc                      a  ] tR t^et o Rt/ t]P                  t/ t	]P                  tRR ltR tR tR tR tR tR tV 3R	 ltR
tV tR# )
BaseParsera1  Parser engine.

A Parser instance contains state pertaining to the current token
sequence, and should not be used concurrently by different threads
to parse separate token sequences.

See python/tokenize.py for how to get input tokens by a string.

When a syntax error occurs, error_recovery() is called.
c                *    Wn         W n        W0n        R # r	   )_pgen_grammar_start_nonterminal_error_recovery)r   pgen_grammarstart_nonterminalerror_recoverys   &&&&r   r   BaseParser.__init__w   s    )"3-r   c                "   V P                   P                  V P                  ,          ^ ,          p\        \	        V4      .4      V n        V F  pV P                  V4       K  	   V P
                  R,          pVP                  P                  '       g-   \        RXP                  VP                  VP                  4      h\        V P
                  4      ^8  d   V P                  4        K  V P                  VP                   VP"                  4      # )    zincomplete input)rR   nonterminal_to_dfasrS   r'   r8   stack
_add_tokenr+   r.   r   r!   stringr#   len_popconvert_noder@   r;   )r   tokens	first_dfatokentoss   &&   r   parseBaseParser.parse|   s    &&::4;R;RSTUV	Ii012
EOOE"  **R.C77### )&

ELL%//  4::"		((#))DDr   c                    V P                   '       d   \        R 4      hVw  r#rE\        P                  ! W#WE4      p\	        RV4      h)z!Error Recovery is not implementedzSyntaxError: invalid syntax)rT   NotImplementedErrorr   	ErrorLeafr   )r   re   r$   r"   r#   prefixr   s   &&     r   rW   BaseParser.error_recovery   sB    %&IJJ.3+E)iHJ#$A:NNr   c                     V P                   V,          ! V4      pV#   \         d    T P                  Y4      p T# i ; ir	   )node_maprL   default_node)r   r@   childrennodes   &&& r   rb   BaseParser.convert_node   sG    	<==-h7D   	<$$[;D	<s    ==c                ~     V P                   V,          ! W$V4      #   \         d    T P                  Y$T4      u # i ; ir	   )leaf_maprL   default_leaf)r   r$   r"   rl   r#   s   &&&&&r   convert_leafBaseParser.convert_leaf   s?    	?=='&AA 	?$$Uv>>	?s    <<c                x   V P                   pV P                  pVw  rErg\        W$V4      p  VR,          P                  P                  V,          p	 T	P                  TR,          n        T	P                   F  p
TP                  \        T
4      4       K  	  T P                  YEYv4      pTR,          P                   P                  T4       R#   \
         dL    TR,          P                  P                  '       d   T P                  4         K  T P                  T4        R# \         d    \        RYET4      hi ; i)z
This is the only core function for parsing. Here happens basically
everything. Everything is well prepared by the parser generator and we
only apply the necessary steps here.
Nztoo much inputr[   )rR   r]   rN   r+   r,   rL   r.   ra   rW   
IndexErrorr   next_dfa
dfa_pushesappendr8   rw   r;   )r   re   rM   r]   r$   r"   r#   rl   r0   planpushleafs   &&          r   r^   BaseParser._add_token   s    $$

*/'i)'%@

TRy}}00< b	OODLL4) $   vAb	t$  9==)))IIK''. T()95SSTs   $C >D9D9!D9*D9c                N   V P                   P                  4       p\        VP                  4      ^8X  d   VP                  ^ ,          pM0V P	                  VP
                  P                  VP                  4      pV P                   R,          P                  P                  V4       R# )   Nr[   )r]   popr`   r;   rb   r+   r>   r}   )r   rf   new_nodes   &  r   ra   BaseParser._pop   sm    jjnn
 syy>Qyy|H(():):CIIFH

2##H-r   c                   < V ^8  d   Qh/ S[ S[S[S[P                  ,          3,          ;R&   S[ S[S[S[P
                  ,          3,          ;R&   # )   ro   ru   )r   strr   r   BaseNodeLeaf)formatr   s   "r   __annotate__BaseParser.__annotate__e   sD      3T]]++,1  3TYY'(- r   )rT   rR   rS   r]   N)
file_inputF)r   r   r   r   r   ro   r   Noderp   ru   r   rv   r   rg   rW   rb   rw   r^   ra   __annotate_func__r   r   r   s   @r   rP   rP   e   sV     	 02H99L+-H99L.
E,O?%@.E  r   rP   N)r   typingr   r   parsor   parso.pgen2.generatorr   r   r   r   r3   r'   r8   rN   rP   r6   r   r   <module>r      sV   "   0%	 %# # D "
N 
N	m. m.r   