ó
    ÖÁ“i}  ã                   óz   • S SK JrJr  S SKJr  S SKrS SKJr  S SKJrJ	r	  SSK
Jr   " S S	5      r " S
 S\5      rg)é    )ÚIteratorÚList©ÚcopyN)ÚUnexpectedToken)ÚTokenÚLexerThreadé   )ÚParserStatec                   ó¶   • \ rS rSrSrS\S\4S jr\S\4S j5       r	S\
4S	 jrS\\
   4S
 jrS\\
   4S jrSS jrS rSS jrS rS rS rS rS rS rSrg)ÚInteractiveParseré   z²InteractiveParser gives you advanced control over parsing and error handling when parsing with LALR.

For a simpler interface, see the ``on_error`` argument to ``Lark.parse()``.
Úparser_stateÚlexer_threadc                 ó6   • Xl         X l        X0l        S U l        g ©N)Úparserr   r   Úresult)Úselfr   r   r   s       Úa/home/mande/repo/quber/.venv/lib/python3.13/site-packages/lark/parsers/lalr_interactive_parser.pyÚ__init__ÚInteractiveParser.__init__   s   € ØŒØ(ÔØ(ÔØˆ�ó    Úreturnc                 óP   • [         R                  " S[        5        U R                  $ )NzMlexer_state will be removed in subsequent releases. Use lexer_thread instead.)ÚwarningsÚwarnÚDeprecationWarningr   ©r   s    r   Úlexer_stateÚInteractiveParser.lexer_state   s   € ä�ŠÐeÔgyÔzØ× Ñ Ð r   Útokenc                 óR   • U R                   R                  XR                  S:H  5      $ )zžFeed the parser with a token, and advance it to the next state, as if it received it from the lexer.

Note that ``token`` has to be an instance of ``Token``.
ú$END)r   Ú
feed_tokenÚtype©r   r"   s     r   r%   ÚInteractiveParser.feed_token   s$   € ð
 × Ñ ×+Ñ+¨E·:±:ÀÑ3GÓHÐHr   c              #   ó˜   #   • U R                   R                  U R                  5       H  nUv •  U R                  U5      U l        M     g7f)a  Step through the different stages of the parse, by reading tokens from the lexer
and feeding them to the parser, one per iteration.

Returns an iterator of the tokens it encounters.

When the parse is over, the resulting tree can be found in ``InteractiveParser.result``.
N)r   Úlexr   r%   r   r'   s     r   Ú
iter_parseÚInteractiveParser.iter_parse$   s=   é € ð ×&Ñ&×*Ñ*¨4×+<Ñ+<Ö=ˆEØŠKØŸ/™/¨%Ó0ˆDŽKò >ùs   ‚AA
c                 ó4   • [        U R                  5       5      $ )z–Try to feed the rest of the lexer state into the interactive parser.

Note that this modifies the instance in place and does not feed an '$END' Token
)Úlistr+   r   s    r   Úexhaust_lexerÚInteractiveParser.exhaust_lexer0   s   € ô
 �D—O‘OÓ%Ó&Ð&r   Nc                 ó˜   • Ub  [         R                  " SSU5      OU R                  R                  SSSSS5      nU R	                  U5      $ )z8Feed a '$END' Token. Borrows from 'last_token' if given.r$   Ú r   r
   )r   Únew_borrow_posr   Ú_Tokenr%   )r   Ú
last_tokenÚeofs      r   Úfeed_eofÚInteractiveParser.feed_eof8   s[   € à>HÑ>TŒe×"Ò" 6¨2¨zÔ:ÐZ^×ZkÑZk×ZrÑZrÐsyÐ{}ð  @Að  CDð  FGó  [HˆØ�‰˜sÓ#Ð#r   c                 ó"   • U R                  5       $ )z}Create a new interactive parser with a separate state.

Calls to feed_token() won't affect the old instance, and vice-versa.
r   r   s    r   Ú__copy__ÚInteractiveParser.__copy__>   s   € ð
 �y‰y‹{Ðr   c                 ó�   • [        U 5      " U R                  U R                  R                  US9[        U R                  5      5      $ )N©Údeepcopy_values)r&   r   r   r   r   )r   r>   s     r   r   ÚInteractiveParser.copyE   s?   € Ü�DŒzØ�K‰KØ×Ñ×"Ñ"°?Ð"ÐCÜ�×"Ñ"Ó#ó
ð 	
r   c                 ó    • [        U[        5      (       d  gU R                  UR                  :H  =(       a    U R                  UR                  :H  $ )NF)Ú
isinstancer   r   r   )r   Úothers     r   Ú__eq__ÚInteractiveParser.__eq__L   sA   € Ü˜%Ô!2×3Ñ3Øà× Ñ  E×$6Ñ$6Ñ6×b¸4×;LÑ;LÐPU×PbÑPbÑ;bÐbr   c                 ón   • [        U 5      n[        UR                  UR                  UR                  5      $ )z-Convert to an ``ImmutableInteractiveParser``.)r   ÚImmutableInteractiveParserr   r   r   ©r   Úps     r   Úas_immutableÚInteractiveParser.as_immutableR   s&   € ä�‹JˆÜ)¨!¯(©(°A·N±NÀAÇNÁNÓSÐSr   c                 ó  • S/nU R                  5       R                  5        H  u  p#UR                  SU< SU< 35        M      UR                  S[        U R                  R
                  5      -  5        SR                  U5      $ )zAPrint the output of ``choices()`` in a way that's easier to read.zParser choices:z	- z -> zstack size: %sÚ
)ÚchoicesÚitemsÚappendÚlenr   Ústate_stackÚjoin)r   ÚoutÚkÚvs       r   ÚprettyÚInteractiveParser.prettyW   sg   € à Ð!ˆØ—L‘L“N×(Ñ(Ö*‰DˆAØ�JŠJ«ªAÐ.Ö/ñ +à�
‰
Ð#¤c¨$×*;Ñ*;×*GÑ*GÓ&HÑHÔIØ�y‰y˜‹~Ðr   c                 ó„   • U R                   R                  R                  R                  U R                   R                     $ )z¬Returns a dictionary of token types, matched to their action in the parser.

Only returns token types that are accepted by the current state.

Updated by ``feed_token()``.
)r   Ú
parse_confÚparse_tableÚstatesÚpositionr   s    r   rM   ÚInteractiveParser.choices_   s3   € ð × Ñ ×+Ñ+×7Ñ7×>Ñ>¸t×?PÑ?P×?YÑ?YÑZÐZr   c                 óœ  • [        5       n[        U R                  R                  5      n0 Ul        U R                  5        Hv  nUR                  5       (       d  M  U R                  SS9nX$R                  l         UR                  U R                  R                  US5      5        UR                  U5        Mx     U$ ! [         a     M‰  f = f)zWReturns the set of possible tokens that will advance the parser into a new valid state.Fr=   r2   )Úsetr   r   rY   Ú	callbacksrM   Úisupperr%   r   r4   Úaddr   )r   ÚacceptsÚconf_no_callbacksÚtÚ
new_cursors        r   rc   ÚInteractiveParser.acceptsh   s°   € ä“%ˆÜ  ×!2Ñ!2×!=Ñ!=Ó>Ðð ')ÐÔ#Ø—‘–ˆAØ�y‰y�{‹{Ø!ŸY™Y°u˜YÐ=�
Ø5F×'Ñ'Ô2ð#Ø×)Ñ)¨$×*;Ñ*;×*BÑ*BÀ1ÀbÓ*IÔJð —K‘K –Nñ  ð ˆøô	 'ó Úðús   Á;+B=Â=
CÃ
Cc                 ó†   • U R                   R                  U R                  U R                  R                  R
                  S9$ )z9Resume automated parsing from the current state.
        )r5   )r   Úparse_from_stater   r   Ústater5   r   s    r   Úresume_parseÚInteractiveParser.resume_parse{   s6   € ð �{‰{×+Ñ+¨D×,=Ñ,=È$×J[ÑJ[×JaÑJa×JlÑJlÐ+ÐmÐmr   )r   r   r   r   r   )T)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r	   r   Úpropertyr    r   r%   r   r+   r   r/   r7   r:   r   rC   rI   rV   rM   rc   rk   Ú__static_attributes__© r   r   r   r      s”   † ñð¨[ð Èô ð ð!˜[ó !ó ð!ðI ô Ið
1˜H U™Oô 
1ð'˜t E™{ô 'ô$òô
òcòTò
ò[òõ&nr   r   c                   ó4   • \ rS rSrSrSrS rS rS rS r	Sr
g)	rF   é‚   zeSame as ``InteractiveParser``, but operations create a new instance instead
of changing it in-place.
Nc                 óD   • [        U R                  U R                  45      $ r   )Úhashr   r   r   s    r   Ú__hash__Ú#ImmutableInteractiveParser.__hash__‰   s   € Ü�T×&Ñ&¨×(9Ñ(9Ð:Ó;Ð;r   c                 óP   • [        U 5      n[        R                  X!5      Ul        U$ r   )r   r   r%   r   )r   r"   Úcs      r   r%   Ú%ImmutableInteractiveParser.feed_tokenŒ   s"   € Ü�‹JˆÜ$×/Ñ/°Ó9ˆŒØˆr   c                 ób   • U R                  5       nUR                  5         UR                  5       $ )z“Try to feed the rest of the lexer state into the parser.

Note that this returns a new ImmutableInteractiveParser and does not feed an '$END' Token)Ú
as_mutabler/   rI   )r   Úcursors     r   r/   Ú(ImmutableInteractiveParser.exhaust_lexer‘   s+   € ð —‘Ó"ˆØ×ÑÔØ×"Ñ"Ó$Ð$r   c                 ón   • [        U 5      n[        UR                  UR                  UR                  5      $ )z$Convert to an ``InteractiveParser``.)r   r   r   r   r   rG   s     r   r   Ú%ImmutableInteractiveParser.as_mutable™   s&   € ä�‹JˆÜ  §¡¨1¯>©>¸1¿>¹>ÓJÐJr   rt   )rm   rn   ro   rp   rq   r   ry   r%   r/   r   rs   rt   r   r   rF   rF   ‚   s#   † ñð €Fò<òò
%õKr   rF   )Útypingr   r   r   r   Úlark.exceptionsr   Ú
lark.lexerr   r	   Úlalr_parser_stater   r   rF   rt   r   r   Ú<module>rˆ      s7   ð÷ "Ý Û å +ß )Ý *÷qnñ qnôjKÐ!2õ Kr   