Ë
    Kæõi  ã                   ó    — d Z ddlmZmZ ddlmZ ddlmZ  G d„ de«      Z	 G d„ de«      Z
 G d	„ d
e«      Z G d„ d«      Zd„ Z G d„ d«      Zy)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                   ó   — e Zd ZdZd„ Zy)ÚParserSyntaxErrorz_
    Contains error information about the parser tree.

    May be raised as an exception.
    c                 ó    — || _         || _        y ©N)ÚmessageÚ
error_leaf)Úselfr   r   s      ú]/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/parso/parser.pyÚ__init__zParserSyntaxError.__init__&   s   € ØˆŒØ$ˆ�ó    N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   © r   r   r   r       s   „ ñó
%r   r   c                   ó   — e Zd ZdZd„ Zy)Ú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           
      óš   — t         j                  | |›d|j                  ›d|›d|›�«       || _        t        | _        || _        || _        y )Nz: type=z, value=z, start_pos=)Ú	Exceptionr   ÚnameÚmsgÚtypeÚvalueÚ	start_pos)r   r   Útype_r   r   s        r   r   zInternalParseError.__init__2   sA   € Ü×Ñ˜4Ú §£ªU±Ið"?ô 	@àˆŒÜˆŒ	ØˆŒ
Ø"ˆ�r   Nr   r   r   r   r   r   +   s   „ ñó#r   r   c                   ó   — e Zd Zd„ Zy)ÚStackc                 ó.   ‡ — ˆ fd„}t         |«       «      S )Nc               3   óÚ   •K  — t        ‰«      D ]X  } | j                  j                  D ]%  }t        |t        «      r|j
                  –— Œ"|–— Œ' | j                  j                  rŒX y  y ­wr
   )ÚreversedÚdfaÚtransitionsÚ
isinstancer   r   Úis_final)Ú
stack_nodeÚ
transitionr   s     €r   Úiteratez@Stack._allowed_transition_names_and_token_types.<locals>.iterate=   sW   øè ø€ ä& tžn�
Ø",§.¡.×"<Ô"<�JÜ! *¬nÔ=Ø(×.Ñ.Ó.à(Ó(ð	 #=ð "—~‘~×.Ó.Ùñ -ùs   ƒA#A+Á'A+)Úlist)r   r,   s   ` r   Ú)_allowed_transition_names_and_token_typesz/Stack._allowed_transition_names_and_token_types<   s   ø€ ô
	ô ‘G“I‹Ðr   N)r   r   r   r.   r   r   r   r"   r"   ;   s   „ ór   r"   c                   ó(   — e Zd Zd„ Zed„ «       Zd„ Zy)Ú	StackNodec                 ó    — || _         g | _        y r
   )r&   Únodes)r   r&   s     r   r   zStackNode.__init__M   s   € ØˆŒØˆ�
r   c                 ó.   — | j                   j                  S r
   )r&   Ú	from_rule©r   s    r   ÚnonterminalzStackNode.nonterminalQ   s   € à�x‰x×!Ñ!Ð!r   c                 óh   — | j                   j                  ›d| j                  ›d| j                  ›d�S )NÚ(z, Ú))Ú	__class__r   r&   r2   r5   s    r   Ú__repr__zStackNode.__repr__U   s!   € Ø#Ÿ~™~×6Ó6¸¿»À$Ç*Ã*ÐMÐMr   N)r   r   r   r   Úpropertyr6   r;   r   r   r   r0   r0   L   s!   „ òð ñ"ó ð"óNr   r0   c                 ór   — |j                   j                  r	 | j                  |   S |S # t        $ r Y |S w xY wr
   )r   Úcontains_syntaxÚreserved_syntax_stringsÚKeyError)Úgrammarr    r   s      r   Ú_token_to_transitionrB   Y   sE   € à‡{�{×"Ò"ð	Ø×2Ñ2°5Ñ9Ð9ð €Løô ò 	Øà€Lð	ús   ˜) ©	6µ6c                   óÒ   — e Zd ZU dZi Zeeeej                     f   e
d<   ej                  Zi Zeeeej                     f   e
d<   ej                  Zdd„Zd„ Zd„ Zd„ Zd„ Zd	„ Zd
„ Zy)Ú
BaseParseraI  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                 ó.   — || _         || _        || _        y r
   )Ú_pgen_grammarÚ_start_nonterminalÚ_error_recovery)r   Úpgen_grammarÚstart_nonterminalÚerror_recoverys       r   r   zBaseParser.__init__w   s   € Ø)ˆÔØ"3ˆÔØ-ˆÕr   c                 óö  — | j                   j                  | j                     d   }t        t	        |«      g«      | _        |D ]  }| j                  |«       Œ 	 | j
                  d   }|j                  j                  s,t        dj                  |j                  |j                  «      ‚t        | j
                  «      dkD  r| j                  «        n&| j                  |j                   |j"                  «      S Œ¡)Nr   éÿÿÿÿzincomplete inputé   )rH   Únonterminal_to_dfasrI   r"   r0   ÚstackÚ
_add_tokenr&   r)   r   r   Ústringr   ÚlenÚ_popÚconvert_noder6   r2   )r   ÚtokensÚ	first_dfaÚtokenÚtoss        r   Úparsez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                 ó†   — | j                   rt        d«      ‚|\  }}}}t        j                  ||||«      }t	        d|«      ‚)Nz!Error Recovery is not implementedzSyntaxError: invalid syntax)rJ   ÚNotImplementedErrorr   Ú	ErrorLeafr   )r   rZ   r    r   r   Úprefixr   s          r   rM   zBaseParser.error_recovery’   sG   € Ø×ÒÜ%Ð&IÓJÐJà.3Ñ+ˆE�5˜) VÜŸ™¨¨u°iÀÓHˆJÜ#Ð$AÀ:ÓNÐNr   c                 óv   — 	  | j                   |   |«      }|S # t        $ r | j                  ||«      }Y |S w xY wr
   )rE   r@   Údefault_node)r   r6   ÚchildrenÚnodes       r   rW   zBaseParser.convert_nodeš   sK   € ð	<Ø-�4—=‘= Ñ-¨hÓ7ˆDð ˆøô ò 	<Ø×$Ñ$ [°(Ó;‰DØˆð	<ús   ‚ ™8·8c                 óv   — 	  | j                   |   |||«      S # t        $ r | j                  |||«      cY S w xY wr
   )rF   r@   Údefault_leaf)r   r    r   r`   r   s        r   Úconvert_leafzBaseParser.convert_leaf¡   sE   € ð	?Ø'�4—=‘= Ñ'¨¨y¸&ÓAÐAøÜò 	?Ø×$Ñ$ U¨I°vÓ>Ò>ð	?ús   ‚ ™8·8c                 óB  — | j                   }| j                  }|\  }}}}t        |||«      }	 	 |d   j                  j                  |   }		 |	j                  |d   _        |	j                  D ]  }
|j                  t        |
«      «       Œ | j                  ||||«      }|d   j                   j                  |«       y# t
        $ r@ |d   j                  j                  r| j                  «        n| j                  |«       Y yY nt        $ r t        d|||«      ‚w xY wŒó)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.
        rO   Nztoo much input)rH   rR   rB   r&   r'   r@   r)   rV   rM   Ú
IndexErrorr   Únext_dfaÚ
dfa_pushesÚappendr0   rg   r2   )r   rZ   rA   rR   r    r   r   r`   r+   ÚplanÚpushÚleafs               r   rS   zBaseParser._add_token§   s  € ð ×$Ñ$ˆØ—
‘
ˆØ*/Ñ'ˆˆu�i Ü)¨'°5¸%Ó@ˆ
àð
TØ˜R‘y—}‘}×0Ñ0°Ñ<�Øð Ÿ™ˆˆb‰	Œà—O”OˆDØ�L‰Lœ 4›Õ)ð $ð × Ñ  ¨¨v°yÓAˆØˆb‰	�‰×Ñ˜tÕ$øô ò Ø˜‘9—=‘=×)Ò)Ø—I‘I•Kà×'Ñ'¨Ô.Ùñ  ô ò TÜ(Ð)9¸5À%ÈÓSÐSðTúð s   ¯B> Â>ADÄDc                 ó8  — | j                   j                  «       }t        |j                  «      dk(  r|j                  d   }n0| j	                  |j
                  j                  |j                  «      }| j                   d   j                  j                  |«       y )NrP   r   rO   )rR   ÚpoprU   r2   rW   r&   r4   rl   )r   r[   Únew_nodes      r   rV   zBaseParser._popÇ   sm   € Ø�j‰j�n‰nÓˆô
 ˆs�y‰y‹>˜QÒØ—y‘y ‘|‰Hà×(Ñ(¨¯©×):Ñ):¸C¿I¹IÓFˆHà�
‰
�2‰×Ñ×#Ñ# HÕ-r   N)Ú
file_inputF)r   r   r   r   rE   r   Ústrr   r   ÚBaseNodeÚ__annotations__ÚNoderb   rF   ÚLeafrf   r   r\   rM   rW   rg   rS   rV   r   r   r   rD   rD   e   sz   … ñ	ð 02€Hˆd�3˜˜TŸ]™]Ñ+Ð+Ñ,Ó1Ø—9‘9€Là+-€Hˆd�3˜˜TŸY™Y™Ð'Ñ(Ó-Ø—9‘9€Ló.ò
Eò,Oòò?ò%ó@.r   rD   N)r   Útypingr   r   Úparsor   Úparso.pgen2.generatorr   r   r   r   r-   r"   r0   rB   rD   r   r   r   Ú<module>r|      sV   ðñ÷" å Ý 0ô%˜	ô %ô#˜ô #ô ˆDô ÷"
Nñ 
Nò	÷m.ò m.r   