
    h}                         S r SSKJrJr  SSKJrJr  SSKJr  SSK	J
r
  SSKJr   " S S	\5      r " S
 S\
\5      r " S S\5      rg)z@Provides a post-lexer for implementing Python-style indentation.    )ABCabstractmethod)ListIterator   )	LarkError)PostLex)Tokenc                       \ rS rSrSrg)DedentError    N)__name__
__module____qualname____firstlineno____static_attributes__r       `C:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\lark/indenter.pyr   r      s    r   r   c                   J   \ rS rSr% Sr\\S'   \\   \S'   SS jrS\	S\
\	   4S	 jrS
 rS r\S 5       r\\S\4S j5       5       r\\S\\   4S j5       5       r\\S\\   4S j5       5       r\\S\4S j5       5       r\\S\4S j5       5       r\\S\4S j5       5       rSrg)Indenter   a  This is a postlexer that "injects" indent/dedent tokens based on indentation.

It keeps track of the current indentation, as well as the current level of parentheses.
Inside parentheses, the indentation is ignored, and no indent/dedent tokens get generated.

Note: This is an abstract class. To use it, inherit and implement all its abstract methods:
    - tab_len
    - NL_type
    - OPEN_PAREN_types, CLOSE_PAREN_types
    - INDENT_type, DEDENT_type

See also: the ``postlex`` option in `Lark`.
paren_levelindent_levelreturnNc                 F    SU l         S/U l        U R                  S:  d   eg Nr   )r   r   tab_lenselfs    r   __init__Indenter.__init__    s&    C||ar   tokenc              #     #    U R                   S:  a  g Uv   UR                  SS5      S   nUR                  S5      UR                  S5      U R                  -  -   nX0R                  S   :  a?  U R                  R                  U5        [        R                  " U R                  X!5      v   g X0R                  S   :  aQ  U R                  R                  5         [        R                  " U R                  X!5      v   X0R                  S   :  a  MQ  X0R                  S   :w  a   [        SU< SU R                  S   < 35      eg 7f)	Nr   
r    	zUnexpected dedent to column z. Expected dedent to )r   rsplitcountr   r   appendr
   new_borrow_posINDENT_typepopDEDENT_typer   )r    r#   
indent_strindents       r   	handle_NLIndenter.handle_NL%   s    a\\$*1-
!!#&)9)9$)?$,,)NN%%b))$$V,&&t'7'7KK,,R00!!%%'**4+;+;ZOO ,,R00 **2..!]ceievevwyez"{|| /s   DE3Ec              #     #    U H  nUR                   U R                  :X  a  U R                  U5       S h  vN   OUv   UR                   U R                  ;   a  U =R                  S-  sl        Ml  UR                   U R
                  ;   d  M  U =R                  S-  sl        U R                  S:  a  M   e   [        U R                  5      S:  aM  U R                  R                  5         [        U R                  S5      v   [        U R                  5      S:  a  MM  U R                  S/:X  d   U R                  5       eg  GN7f)Nr   r    )typeNL_typer2   OPEN_PAREN_typesr   CLOSE_PAREN_typeslenr   r.   r
   r/   )r    streamr#   s      r   _processIndenter._process9   s    EzzT\\)>>%000zzT222  A% t555  A% ''1,,,  $##$q(!!#(("-- $##$q(   QC':):)::' 1s#   4EEAE#E4A(E$Ec                 B    SU l         S/U l        U R                  U5      $ r   )r   r   r<   )r    r;   s     r   processIndenter.processL   s#    C}}V$$r   c                     U R                   4$ )N)r7   r   s    r   always_acceptIndenter.always_acceptR   s    r   c                     [        5       e)zThe name of the newline tokenNotImplementedErrorr   s    r   r7   Indenter.NL_typeV        "##r   c                     [        5       e)z/The names of the tokens that open a parenthesisrE   r   s    r   r8   Indenter.OPEN_PAREN_types\   rH   r   c                     [        5       e)z9The names of the tokens that close a parenthesis
        rE   r   s    r   r9   Indenter.CLOSE_PAREN_typesb   s    
 "##r   c                     [        5       e)zUThe name of the token that starts an indentation in the grammar.

See also: %declare
rE   r   s    r   r-   Indenter.INDENT_typei        "##r   c                     [        5       e)zRThe name of the token that end an indentation in the grammar.

See also: %declare
rE   r   s    r   r/   Indenter.DEDENT_typer   rO   r   c                     [        5       e)z How many spaces does a tab equalrE   r   s    r   r   Indenter.tab_len{   rH   r   )r   r   )r   N)r   r   r   r   __doc__int__annotations__r   r!   r
   r   r2   r<   r?   propertyrB   r   strr7   r8   r9   r-   r/   r   r   r   r   r   r   r      s0    s) 
}u }% }(;&%   $ $  $ $$s) $  $ $49 $  $
 $S $  $ $S $  $ $ $  $r   r   c                   8    \ rS rSrSrSr/ SQr/ SQrSrSr	Sr
S	rg
)PythonIndenter   zA postlexer that "injects" _INDENT/_DEDENT tokens based on indentation, according to the Python syntax.

See also: the ``postlex`` option in `Lark`.
_NEWLINE)LPARLSQBLBRACE)RPARRSQBRBRACE_INDENT_DEDENT   r   N)r   r   r   r   rT   r7   r8   r9   r-   r/   r   r   r   r   r   rZ   rZ      s)    
 G12KKGr   rZ   N)rT   abcr   r   typingr   r   
exceptionsr   larkr	   lexerr
   r   r   rZ   r   r   r   <module>rk      s@    B # ! !  	) 	p$w p$fX r   