ó
    Ð]j  ã                   ó    • S r SSKJrJr  SSKJr  SSKJr   " S S\5      r	 " S S\5      r
 " S	 S
\5      r " S S5      rS r " S S5      rg)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                   ó   • \ rS rSrSrS rSrg)ÚParserSyntaxErroré    zS
Contains error information about the parser tree.

May be raised as an exception.
c                 ó   • Xl         X l        g ©N)ÚmessageÚ
error_leaf)Úselfr   r   s      ÚI/home/mande/repo/quber/.venv/lib/python3.13/site-packages/parso/parser.pyÚ__init__ÚParserSyntaxError.__init__&   s   € ØŒØ$�ó    )r   r   N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Ú__static_attributes__© r   r   r   r       s   † ñõ
%r   r   c                   ó   • \ rS rSrSrS rSrg)ÚInternalParseErroré+   z–
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           
      óœ   • [         R                  U U< SUR                  < SU< SU< 35        Xl        [        U l        X0l        X@l        g )Nz: type=z, value=z, start_pos=)Ú	Exceptionr   ÚnameÚmsgÚtypeÚvalueÚ	start_pos)r   r!   Útype_r#   r$   s        r   r   ÚInternalParseError.__init__2   s;   € Ü×Ñ˜4Û §¤«U²Ið"?ô 	@àŒÜˆŒ	ØŒ
Ø"�r   )r!   r$   r"   r#   Nr   r   r   r   r   r   +   s   † ñõ#r   r   c                   ó   • \ rS rSrS rSrg)ÚStacké;   c                 ó0   ^ • U 4S jn[        U" 5       5      $ )Nc               3   óø   >#   • [        T5       Hf  n U R                  R                   H,  n[        U[        5      (       a  UR
                  v •  M(  Uv •  M.     U R                  R                  (       a  Mf    g    g 7fr   )ÚreversedÚdfaÚtransitionsÚ
isinstancer   r#   Úis_final)Ú
stack_nodeÚ
transitionr   s     €r   ÚiterateÚ@Stack._allowed_transition_names_and_token_types.<locals>.iterate=   s\   øé € ä& tžn�
Ø",§.¡.×"<Ô"<�JÜ! *¬n×=Ñ=Ø(×.Ñ.Ô.à(Ô(ñ	 #=ð "—~‘~×.×.Ñ.Ùò -ùs   ƒA.A:Á5A:)Úlist)r   r3   s   ` r   Ú)_allowed_transition_names_and_token_typesÚ/Stack._allowed_transition_names_and_token_types<   s   ø€ õ
	ô ‘G“I‹Ðr   r   N)r   r   r   r   r6   r   r   r   r   r(   r(   ;   s   † õr   r(   c                   ó0   • \ rS rSrS r\S 5       rS rSrg)Ú	StackNodeéL   c                 ó   • Xl         / U l        g r   ©r-   Únodes)r   r-   s     r   r   ÚStackNode.__init__M   s   € ØŒØˆ�
r   c                 ó.   • U R                   R                  $ r   )r-   Ú	from_rule©r   s    r   ÚnonterminalÚStackNode.nonterminalQ   s   € à�x‰x×!Ñ!Ð!r   c                 ón   • U R                   R                  < SU R                  < SU R                  < S3$ )NÚ(z, Ú))Ú	__class__r   r-   r=   rA   s    r   Ú__repr__ÚStackNode.__repr__U   s!   € Ø#Ÿ~™~×6Ô6¸¿¼À$Ç*Ä*ÐMÐMr   r<   N)	r   r   r   r   r   ÚpropertyrB   rH   r   r   r   r   r9   r9   L   s!   † òð ñ"ó ð"õNr   r9   c                 ó~   • UR                   R                  (       a   U R                  U   $ U$ ! [         a     U$ f = fr   )r#   Úcontains_syntaxÚreserved_syntax_stringsÚKeyError)Úgrammarr%   r#   s      r   Ú_token_to_transitionrP   Y   sE   € à‡{�{×"×"ð	Ø×2Ñ2°5Ñ9Ð9ð €Løô ó 	Øà€Lð	ús   �. ®
<»<c                   óÜ   • \ rS rSr% Sr0 r\\\\	R                     4   \S'   \	R                  r0 r\\\\	R                     4   \S'   \	R                  rSS jrS rS rS rS	 rS
 rS rSrg)Ú
BaseParserée   a1  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.
Únode_mapÚleaf_mapc                 ó(   • Xl         X l        X0l        g r   )Ú_pgen_grammarÚ_start_nonterminalÚ_error_recovery)r   Úpgen_grammarÚstart_nonterminalÚerror_recoverys       r   r   ÚBaseParser.__init__w   s   € Ø)ÔØ"3ÔØ-Õr   c                 ó  • U R                   R                  U R                     S   n[        [	        U5      /5      U l        U H  nU R                  U5        M      U R
                  S   nUR                  R                  (       d,  [        SWR                  UR                  UR                  5      e[        U R
                  5      S:”  a  U R                  5         O&U R                  UR                   UR"                  5      $ M¨  )Nr   éÿÿÿÿzincomplete inputé   )rW   Únonterminal_to_dfasrX   r(   r9   ÚstackÚ
_add_tokenr-   r0   r   r"   Ústringr$   ÚlenÚ_popÚconvert_noderB   r=   )r   ÚtokensÚ	first_dfaÚtokenÚtoss        r   ÚparseÚBaseParser.parse|   sÌ   € Ø×&Ñ&×:Ñ:¸4×;RÑ;RÑSÐTUÑVˆ	ÜœI iÓ0Ð1Ó2ˆŒ
ãˆEØ�O‰O˜EÖ"ñ ð Ø—*‘*˜R‘.ˆCØ—7‘7×#×#ô )Ø&¨¯
©
°E·L±LÀ%Ç/Á/óð ô �4—:‘:‹ Ó"Ø—	‘	•à×(Ñ(¨¯©¸#¿)¹)ÓDÐDñ r   c                 óŠ   • U R                   (       a  [        S5      eUu  p#pE[        R                  " X#XE5      n[	        SU5      e)Nz!Error Recovery is not implementedzSyntaxError: invalid syntax)rY   ÚNotImplementedErrorr   Ú	ErrorLeafr   )r   rj   r%   r#   r$   Úprefixr   s          r   r\   ÚBaseParser.error_recovery’   s?   € Ø××Ü%Ð&IÓJÐJà.3Ñ+ˆE˜)ÜŸš¨°iÓHˆJÜ#Ð$AÀ:ÓNÐNr   c                 óv   •  U R                   U   " U5      nU$ ! [         a    U R                  X5      n U$ f = fr   )rT   rN   Údefault_node)r   rB   ÚchildrenÚnodes       r   rg   ÚBaseParser.convert_nodeš   sG   € ð	<Ø—=‘= Ò-¨hÓ7ˆDð ˆøô ó 	<Ø×$Ñ$ [Ó;‰DØˆð	<ús   ‚ ™8·8c                 ót   •  U R                   U   " X$U5      $ ! [         a    U R                  X$U5      s $ f = fr   )rU   rN   Údefault_leaf)r   r%   r#   rq   r$   s        r   Úconvert_leafÚBaseParser.convert_leaf¡   s?   € ð	?Ø—=‘= Ò'¨¸&ÓAÐAøÜó 	?Ø×$Ñ$ U°vÓ>Ò>ð	?ús   ‚ ˜7¶7c                 óH  • U R                   nU R                  nUu  pEpg[        X$U5      n  US   R                  R                  U   n	 U	R                  US   l        U	R                   H  n
UR                  [        U
5      5        M     U R                  XEXv5      nUS   R                   R                  U5        g! [
         aD    US   R                  R                  (       a  U R                  5          O-U R                  U5         g[         a    [        SXEU5      ef = fMù  )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.
r_   Nztoo much input)rW   rb   rP   r-   r.   rN   r0   rf   r\   Ú
IndexErrorr   Únext_dfaÚ
dfa_pushesÚappendr9   rz   r=   )r   rj   rO   rb   r%   r#   r$   rq   r2   ÚplanÚpushÚleafs               r   rc   ÚBaseParser._add_token§   s  € ð ×$Ñ$ˆØ—
‘
ˆØ*/Ñ'ˆ�iÜ)¨'¸%Ó@ˆ
àð
TØ˜R‘y—}‘}×0Ñ0°Ñ<�Øð Ÿ™ˆˆb‰	Œà—O”OˆDØ�L‰Lœ 4›Ö)ñ $ð × Ñ  ¨vÓAˆØˆb‰	�‰×Ñ˜tÕ$øô ó Ø˜‘9—=‘=×)×)Ø—I‘I–Kà×'Ñ'¨Ô.ÙÜó TÜ(Ð)9¸5ÈÓSÐSðTúñ s   ¬B; Â;8DÃ5DÄDc                 ó:  • U R                   R                  5       n[        UR                  5      S:X  a  UR                  S   nO0U R	                  UR
                  R                  UR                  5      nU R                   S   R                  R                  U5        g )Nr`   r   r_   )rb   Úpopre   r=   rg   r-   r@   r€   )r   rk   Únew_nodes      r   rf   ÚBaseParser._popÇ   sm   € Ø�j‰j�n‰nÓˆô
 ˆs�y‰y‹>˜QÓØ—y‘y ‘|‰Hà×(Ñ(¨¯©×):Ñ):¸C¿I¹IÓFˆHà�
‰
�2‰×Ñ×#Ñ# HÕ-r   )rY   rW   rX   rb   N)Ú
file_inputF)r   r   r   r   r   rT   r   Ústrr   r   ÚBaseNodeÚ__annotations__ÚNodert   rU   ÚLeafry   r   rl   r\   rg   rz   rc   rf   r   r   r   r   rR   rR   e   sz   ‡ ñ	ð 02€Hˆd�3˜˜TŸ]™]Ñ+Ð+Ñ,Ó1Ø—9‘9€Là+-€Hˆd�3˜˜TŸY™Y™Ð'Ñ(Ó-Ø—9‘9€Lô.ò
Eò,Oòò?ò%õ@.r   rR   N)r   Útypingr   r   Úparsor   Úparso.pgen2.generatorr   r   r   r   r5   r(   r9   rP   rR   r   r   r   Ú<module>r’      sV   ðñ÷" å Ý 0ô%˜	ô %ô#˜ô #ô ˆDô ÷"
Nñ 
Nò	÷m.ò m.r   