§
    ŒŸj  ã                   óÀ   — 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dS )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dS )ÚParserSyntaxErrorz_
    Contains error information about the parser tree.

    May be raised as an exception.
    c                 ó"   — || _         || _        d S ©N)ÚmessageÚ
error_leaf)Úselfr   r   s      úY/var/www/finuniver-perm.ru/html/student/venv/lib/python3.11/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dS )Ú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                                | |›d|j        ›d|›d|›�¦  «         || _        t          | _        || _        || _        d S )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   s]   € Ý×Ò˜4Ø˜C˜C ¤  ¨U¨U¨U°I°Ið"?ñ 	@ô 	@ð 	@àˆŒÝˆŒ	ØˆŒ
Ø"ˆŒˆˆr   Nr   r   r   r   r   r   +   s-   € € € € € ðð ð#ð #ð #ð #ð #r   r   c                   ó   — e Zd Zd„ ZdS )ÚStackc                 ó<   ‡ — ˆ fd„}t           |¦   «         ¦  «        S )Nc               3   ó²   •K  — t          ‰¦  «        D ]C} | j        j        D ]%}t          |t          ¦  «        r
|j        V — Œ!|V — Œ&| j        j        s d S ŒDd S r
   )ÚreversedÚdfaÚtransitionsÚ
isinstancer   r   Úis_final)Ú
stack_nodeÚ
transitionr   s     €r   Úiteratez@Stack._allowed_transition_names_and_token_types.<locals>.iterate=   s†   øè è € å& t™nœnð ð �
Ø",¤.Ô"<ð )ð )�JÝ! *­nÑ=Ô=ð )Ø(Ô.Ð.Ð.Ð.Ð.à(Ð(Ð(Ð(Ð(à!”~Ô.ð Ø�E�Eððð r   )Úlist)r   r,   s   ` r   Ú)_allowed_transition_names_and_token_typesz/Stack._allowed_transition_names_and_token_types<   s0   ø€ ð
	ð 
	ð 
	ð 
	ð 
	õ �G�G‘I”I‰ŒÐr   N)r   r   r   r.   r   r   r   r"   r"   ;   s#   € € € € € ðð ð ð ð r   r"   c                   ó0   — e Zd Zd„ Zed„ ¦   «         Zd„ ZdS )Ú	StackNodec                 ó"   — || _         g | _        d S 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Ô!Ð!r   c                 ó@   — | 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Ð6¸¼¸¸À$Ä*À*À*ÐMÐMr   N)r   r   r   r   Úpropertyr6   r;   r   r   r   r0   r0   L   sR   € € € € € ðð ð ð ð"ð "ñ „Xð"ðNð Nð Nð Nð Nr   r0   c                 óZ   — |j         j        r	 | j        |         S # t          $ r Y nw xY w|S r
   )r   Úcontains_syntaxÚreserved_syntax_stringsÚKeyError)Úgrammarr    r   s      r   Ú_token_to_transitionrB   Y   sI   € à„{Ô"ð ð	ØÔ2°5Ô9Ð9øÝð 	ð 	ð 	ØˆDð	øøøð €Ls   Ž ›
(§(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dS )Ú
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_mapÚ
file_inputFc                 ó0   — || _         || _        || _        d S 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        d         }|j        j        s!t          d|j
        |j        |j        ¦  «        ‚t          | j        ¦  «        dk    r|                      ¦   «          n |                      |j        |j        ¦  «        S Œˆ)Nr   Téÿÿÿÿzincomplete inputé   )rI   Únonterminal_to_dfasrJ   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ÔSÐTUÔVˆ	Ý�I iÑ0Ô0Ð1Ñ2Ô2ˆŒ
àð 	#ð 	#ˆEØ�OŠO˜EÑ"Ô"Ð"Ð"ð	EØ”*˜R”.ˆCØ”7Ô#ð õ )Ø&¨¬
°E´LÀ%Ä/ñô ð õ �4”:‰Œ Ò"Ð"Ø—	’	‘”��à×(Ò(¨¬¸#¼)ÑDÔDÐDð	Er   c                 óŠ   — | j         rt          d¦  «        ‚|\  }}}}t          j        ||||¦  «        }t	          d|¦  «        ‚)Nz!Error Recovery is not implementedzSyntaxError: invalid syntax)rK   ÚNotImplementedErrorr   Ú	ErrorLeafr   )r   r[   r    r   r   Úprefixr   s          r   rN   zBaseParser.error_recovery’   sQ   € ØÔð 	OÝ%Ð&IÑJÔJÐJà.3Ñ+ˆE�5˜) VÝœ¨¨u°iÀÑHÔHˆJÝ#Ð$AÀ:ÑNÔNÐNr   c                 ó‚   — 	  | j         |         |¦  «        }n&# t          $ r |                      ||¦  «        }Y nw xY w|S r
   )rE   r@   Údefault_node)r   r6   ÚchildrenÚnodes       r   rX   zBaseParser.convert_nodeš   sX   € ð	<Ø-�4”= Ô-¨hÑ7Ô7ˆDˆDøÝð 	<ð 	<ð 	<Ø×$Ò$ [°(Ñ;Ô;ˆDˆDˆDð	<øøøàˆs   ‚ ™ <»<c                 ó‚   — 	  | j         |         |||¦  «        S # t          $ r |                      |||¦  «        cY S w xY wr
   )rF   r@   Údefault_leaf)r   r    r   ra   r   s        r   Úconvert_leafzBaseParser.convert_leaf¡   s[   € ð	?Ø'�4”= Ô'¨¨y¸&ÑAÔAÐAøÝð 	?ð 	?ð 	?Ø×$Ò$ U¨I°vÑ>Ô>Ð>Ð>Ð>ð	?øøøs   ‚ š!>½>c                 óJ  — | j         }| j        }|\  }}}}t          |||¦  «        }	 	 |d         j        j        |         }	nk# t
          $ rB |d         j        j        r|                      ¦   «          n|                      |¦  «         Y dS Y nt          $ r t          d|||¦  «        ‚w xY wŒ…|	j        |d         _        |	j        D ]$}
|                     t          |
¦  «        ¦  «         Œ%|                      ||||¦  «        }|d         j                             |¦  «         dS )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.
        TrP   Nztoo much input)rI   rS   rB   r&   r'   r@   r)   rW   rN   Ú
IndexErrorr   Únext_dfaÚ
dfa_pushesÚappendr0   rh   r2   )r   r[   rA   rS   r    r   r   ra   r+   ÚplanÚpushÚleafs               r   rT   zBaseParser._add_token§   sX  € ð Ô$ˆØ”
ˆØ*/Ñ'ˆˆu�i Ý)¨'°5¸%Ñ@Ô@ˆ
ð	Tð
TØ˜R”y”}Ô0°Ô<�ØøÝð ð ð Ø˜”9”=Ô)ð Ø—I’I‘K”K�K�Kà×'Ò'¨Ñ.Ô.Ð.Ø�F�Fð  �Kõ ð Tð Tð TÝ(Ð)9¸5À%ÈÑSÔSÐSðTøøøð	Tð œˆˆbŒ	Œà”Oð 	*ð 	*ˆDØ�LŠL� 4™œÑ)Ô)Ð)Ð)à× Ò  ¨¨v°yÑAÔAˆØˆbŒ	Œ×Ò˜tÑ$Ô$Ð$Ð$Ð$s   ©A ÁAB)ÂB)c                 ó  — | j                              ¦   «         }t          |j        ¦  «        dk    r|j        d         }n%|                      |j        j        |j        ¦  «        }| j         d         j                             |¦  «         d S )NrQ   r   rP   )rS   ÚpoprV   r2   rX   r&   r4   rm   )r   r\   Únew_nodes      r   rW   zBaseParser._popÇ   st   € ØŒj�nŠnÑÔˆõ
 ˆsŒy‰>Œ>˜QÒÐØ”y ”|ˆHˆHà×(Ò(¨¬Ô):¸C¼IÑFÔFˆHàŒ
�2ŒÔ×#Ò# HÑ-Ô-Ð-Ð-Ð-r   N)rG   F)r   r   r   r   rE   r   Ústrr   r   ÚBaseNodeÚ__annotations__ÚNoderc   rF   ÚLeafrg   r   r]   rN   rX   rh   rT   rW   r   r   r   rD   rD   e   sæ   € € € € € € ð	ð 	ð 02€Hˆd�3˜˜Tœ]Ô+Ð+Ô,Ð1Ð1Ñ1Ø”9€Là+-€Hˆd�3˜˜TœYœÐ'Ô(Ð-Ð-Ñ-Ø”9€Lð.ð .ð .ð .ð
Eð Eð Eð,Oð Oð Oðð ð ð?ð ?ð ?ð%ð %ð %ð@.ð .ð .ð .ð .r   rD   N)r   Útypingr   r   Úparsor   Úparso.pgen2.generatorr   r   r   r   r-   r"   r0   rB   rD   r   r   r   ú<module>r|      sF  ððð ð" Ð Ð Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0ð%ð %ð %ð %ð %˜	ñ %ô %ð %ð#ð #ð #ð #ð #˜ñ #ô #ð #ð ð ð ð ð ˆDñ ô ð ð"
Nð 
Nð 
Nð 
Nð 
Nñ 
Nô 
Nð 
Nð	ð 	ð 	ðm.ð m.ð m.ð m.ð m.ñ m.ô m.ð m.ð m.ð m.r   