
    5i                        S SK Jr  S SKJr  S SK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)    )annotations)copy)Any)
ParseError)UnexpectedCharError)TOMLCharc                  D    \ rS rSr  S       SS jjrS	S jrS rSrg)
_State   c                (    Xl         X l        X0l        g N)_source_save_markerrestore)selfsourcesave_markerr   s       .lib/python3.13/site-packages/tomlkit/source.py__init___State.__init__   s     '    c                    [        U R                  R                  5      U l        U R                  R                  U l        U R                  R                  U l        U R                  R
                  U l        U $ r   )r   r   _chars_idx_current_markerr   s    r   	__enter___State.__enter__   sP    4<<../LL%%	--||++r   c                2   U R                   (       d  U(       a  U R                  U R                  l        U R                  U R                  l        U R                  U R                  l        U R
                  (       a  U R                  U R                  l        g g g r   )r   r   r   r   r   r   r   )r   exception_typeexception_valtraces       r   __exit___State.__exit__   s^    <<>"&++DLL $		DLL$(MMDLL!  '+||$ !	 *r   )r   r   r   r   r   r   r   N)FF)r   Sourcer   bool | Noner   r'   returnNoner(   r
   )__name__
__module____qualname____firstlineno__r   r   r$   __static_attributes__ r   r   r
   r
      s?     $)$	 ! 	
 
4r   r
   c                  8    \ rS rSrSrS	S jrS rS
S jrS rSr	g)_StateHandler)   z!
State preserver for the Parser.
c                    Xl         / U l        g r   r   _states)r   r   s     r   r   _StateHandler.__init__.   s    r   c                4    [        U R                  /UQ70 UD6$ r   )r
   r   )r   argskwargss      r   __call___StateHandler.__call__2   s    dll4T4V44r   c                f    U " 5       nU R                   R                  U5        UR                  5       $ r   )r6   appendr   )r   states     r   r   _StateHandler.__enter__5   s(    E"  r   c                Z    U R                   R                  5       nUR                  XU5      $ r   )r6   popr$   )r   r!   r"   r#   r?   s        r   r$   _StateHandler.__exit__:   s%      "~~nUCCr   r5   N)r   r&   r(   r)   r*   )
r+   r,   r-   r.   __doc__r   r;   r   r$   r/   r0   r   r   r2   r2   )   s    5!
Dr   r2   c                     ^  \ rS rSr\" S5      rSU 4S jjrS r\SS j5       r	\SS j5       r
\SS j5       r\SS j5       rSS	 jrSSS
 jjrSSS jjrSS jrSS jrSS jr\4       SS jjrSS jrSrU =r$ )r&   ?    c           
       > [         TU ]  5         [        [        U 5       VVs/ s H  u  p#U[	        U5      4PM     snn5      U l        SU l        SU l        [	        S5      U l        [        U 5      U l
        U R                  5         g s  snnf )Nr    )superr   iter	enumerater   r   r   r   r   r2   _stateinc)r   _ic	__class__s       r   r   Source.__init__B   sn     4IQ,IJ	 #D)
 Js   B
c                D    U R                  5         U R                  5         g r   )rN   markr   s    r   resetSource.resetP   s    
 			r   c                    U R                   $ r   )rM   r   s    r   r?   Source.stateW   s    {{r   c                    U R                   $ r   )r   r   s    r   idx
Source.idx[   s    yyr   c                    U R                   $ r   )r   r   s    r   currentSource.current_   s    }}r   c                    U R                   $ r   )r   r   s    r   markerSource.markerc   s    ||r   c                2    X R                   U R                   $ )z-
Extracts the value between marker and index
)r   r   r   s    r   extractSource.extractg   s     LL499--r   c                     [        U R                  5      u  U l        U l        g! [         a=    [        U 5      U l        U R                  U l        U(       a  U R                  U5      Se gf = f)zt
Increments the parser if the end of the input has not been reached.
Returns whether or not it was able to advance.
TNF)nextr   r   r   StopIterationlenEOFparse_error)r   	exceptions     r   rN   
Source.incm   s_    

	'+DKK'8$DIt} 	D	DI HHDM&&y1t;	s   "% AA,+A,c                D   ^ ^ [        UU 4S j[        U5       5       5      $ )zU
Increments the parser by n characters
if the end of the input has not been reached.
c              3  B   >#    U  H  nTR                  TS 9v   M     g7f))rl   N)rN   ).0rO   rl   r   s     r   	<genexpr>Source.inc_n.<locals>.<genexpr>   s     C(Q488i80(s   )allrange)r   nrl   s   ` `r   inc_nSource.inc_n~   s    
 C%(CCCr   c                    U R                   U;   a>  US:w  a8  US-  nUS-  nU R                  5       (       d  OU R                   U;   a  US:w  a  M8  US:  a   U R                  [        U R                   5      eg)z4
Consume chars until min/max is satisfied is valid.
r      N)r^   rN   rk   r   )r   charsminmaxs       r   consumeSource.consume   sp     lle#q1HC1HC88::	 lle#q 7""#6EE r   c                2    U R                   U R                  L $ )z>
Returns True if the parser has reached the end of the input.
)r   rj   r   s    r   end
Source.end   s     }}((r   c                &    U R                   U l        g)z1
Sets the marker to the index's current position
N)r   r   r   s    r   rU   Source.mark   s     yyr   c                >    U R                  5       u  pEU" XE/UQ70 UD6$ )z:
Creates a generic "parse error" at the current position.
)_to_linecol)r   rl   r9   r:   linecols         r   rk   Source.parse_error   s)     $$&	4T4V44r   c                   Sn[        U R                  5       5       HK  u  p#U[        U5      -   S-   U R                  :  a  US-   U R                  U-
  4s  $ U[        U5      S-   -  nMM     [        U R                  5       5      S4$ )Nr   ry   )rL   
splitlinesri   r[   )r   currP   r   s       r   r   Source._to_linecol   sz     !23GASY"TXX-Atxx#~..3t9q= C	 4 4??$%q((r   )r   r   r   r   rM   )rO   strr(   r)   )r(   r2   )r(   int)r(   r   )r(   r   r   )rl   type[ParseError] | Noner(   bool)ru   r   rl   r   r(   r   )r   )r(   r   )r(   r)   )rl   ztype[ParseError]r9   r   r:   r   r(   r   )r(   ztuple[int, int])r+   r,   r-   r.   r   rj   r   rV   propertyr?   r[   r^   ra   rd   rN   rv   r}   r   rU   r   rk   r   r/   __classcell__)rR   s   @r   r&   r&   ?   s    
4.C        ."DF)! '15#5 5 	5
 
5) )r   r&   N)
__future__r   r   typingr   tomlkit.exceptionsr   r   tomlkit.toml_charr   r
   r2   r   r&   r0   r   r   <module>r      s;    "   ) 2 &4 4<D D,u)S u)r   