
                             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)zNProvides Indentation services for languages with indentation similar to Python    )ABCabstractmethod)ListIterator   )	LarkError)PostLex)Tokenc                       \ rS rSrSrg)DedentError    N)__name__
__module____qualname____firstlineno____static_attributes__r        lib/third_party/lark/indenter.pyr   r      s    r   r   c                   F   \ 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   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._process,   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.process?   s#    C}}V$$r   c                     U R                   4$ N)r7   r   s    r   always_acceptIndenter.always_acceptE   s    r   c                     [        5       erB   NotImplementedErrorr   s    r   r7   Indenter.NL_typeI        "##r   c                     [        5       erB   rF   r   s    r   r8   Indenter.OPEN_PAREN_typesN   rI   r   c                     [        5       erB   rF   r   s    r   r9   Indenter.CLOSE_PAREN_typesS   rI   r   c                     [        5       erB   rF   r   s    r   r-   Indenter.INDENT_typeX   rI   r   c                     [        5       erB   rF   r   s    r   r/   Indenter.DEDENT_type]   rI   r   c                     [        5       erB   rF   r   s    r   r   Indenter.tab_lenb   rI   r   )r   r   )r   N)r   r   r   r   int__annotations__r   r!   r
   r   r2   r<   r?   propertyrC   r   strr7   r8   r9   r-   r/   r   r   r   r   r   r   r      s)   s) 
}u }% }(;&%   $ $  $ $$s) $  $ $49 $  $ $S $  $ $S $  $ $ $  $r   r   c                   4    \ rS rSrSr/ SQr/ SQrSrSrSr	Sr
g	)
PythonIndenterh   _NEWLINE)LPARLSQBLBRACE)RPARRSQBRBRACE_INDENT_DEDENT   r   N)r   r   r   r   r7   r8   r9   r-   r/   r   r   r   r   r   rY   rY   h   s"    G12KKGr   rY   N)__doc__abcr   r   typingr   r   
exceptionsr   larkr	   lexerr
   r   r   rY   r   r   r   <module>rk      s@    P # ! !  	) 	V$w V$rX r   