+
    ^|i                        R t ^ RIHt ^ RIt^ RIt^ RIHt ^ RIHt ^ RIH	t	 ^ RI
Ht ^ RIHt  ! R R	]4      tR
 R ltRR R lltRR R lltRR R lltR# )zToken-related utilities)annotationsN)StringIO)	iskeyword)	TokenInfo)
NamedTuple)	Generatorc                  J    ] tR t^t$ R]R&   R]R&   R]R&   R]R&   R]R&   RtR	# )
Tokeninttokenstrtextstartendline N)__name__
__module____qualname____firstlineno____annotations____static_attributes__r       9/usr/lib/python3/dist-packages/IPython/utils/tokenutil.pyr	   r	      s    J
IJ	H
Ir   r	   c                   V ^8  d   QhRR/# )   returnz Generator[TokenInfo, None, None]r   )formats   "r   __annotate__r      s      !A r   c              #     "    \         P                  ! V 4       Rj  xL
  R#  L  \         P                   d     R# i ; i5i)z'wrap generate_tkens to catch EOF errorsN)tokenizegenerate_tokens
TokenError)readlines   &r   r!   r!      s5     ++H555 s,   A& $& A& ?A?Ac                   V ^8  d   QhRR/# )r   extra_errors_to_catchzlist[str] | Noner   )r   s   "r   r   r   !   s      %5r   c              #    a	"   . ROpVe   \        V\        4      '       g   Q hY!;'       g    . ,           p. p \        P                  ! V 4       F  pVP	                  V4       Vx  K  	  R#   \        P
                   d   o	\        ;QJ d    T	3R lT 4       F  '       g   K   RM	  RM! T	3R lT 4       4      '       d|   T'       dK   TR,          P                  ^ ,          TR,          P                  ^ ,          3pTpTR,          P                  pMR;rgRp\        \        P                  RYgT4      x   Ro	>	R# h Ro	>	ii ; i5i)	unterminated string literalNc              3  N   <"   T F  qSP                   ^ ,          9   x  K  	  R# 5i)    N)args).0errorexcs   & r   	<genexpr>/generate_tokens_catch_errors.<locals>.<genexpr>2   s     A#s   "%TF )r'   zinvalid non-printable characterz!after line continuation character)   r)   )
isinstancelistr    r!   appendr"   anyr   r   r   r   
ERRORTOKEN)
r#   r%   default_errors_to_catcherrors_to_catchtokensr   r   r   r   r-   s
   &&       @r   generate_tokens_catch_errorsr;   !   s    
 !(J7Ld,S,SSS-1L1L"MO F--h7EMM% K 8  3AA333AAAAr
((+VBZ^^A->>bz$$H//UFFF sL   )EE2A- +E-ED>$D>D>
A-D>7E=D>>EEc               $    V ^8  d   QhRRRRRR/# )r   cellr   
cursor_posr
   r   ztuple[str, int]r   )r   s   "r   r   r   @   s!       # o r   c                    ^ pV P                  R4      pV FA  pV\        V4      ,           pVP                  R4      '       g
   V^,          pWQ8  d    WB3# TpKC  	  RpWB3# )ax  Return the line in a cell at a given cursor position

Used for calling line-based APIs that don't support multi-line input, yet.

Parameters
----------
cell : str
    multiline block of text
cursor_pos : integer
    the cursor position

Returns
-------
(line, offset): (string, integer)
    The line with the current cursor, and the character offset of the start of the line.
T
r0   )
splitlineslenendswith)r=   r>   offsetlinesr   next_offsets   &&    r   line_at_cursorrG   @   ss    " FOOD!Es4y(}}T"" 1K# <   <r   c               $    V ^8  d   QhRRRRRR/# )r   r=   r   r>   r
   r   r   )r   s   "r   r   r   b   s&     f f# f3 fs fr   c                   . p. pRpRp^^ /pRpRp\        \        V 4      P                  4       U	u. uF  p	\        V	!  NK  	  p
p	V
'       g   R# \	        R.V
,           \
        P                  ! V
R.,           4      4       EFz  w  pw  rVP                  w  rVP                  w  ppV^,           V9  de   VP                  P                  R4      p\        VV^,           4       F2  w  ppVV9  g   K  VV^,
          ,          \        V4      ,           VV&   K4  	  RpWn,          pVV,           V8  d    EMVP                  \        P                  8H  ;'       d    \!        VP"                  4      '       * ;p'       d   V'       dW   V'       dO   VP                  \        P$                  8X  d0   VP"                  R8X  d   VR	,          : RVP"                  : 2VR	&   MVP'                  VP"                  4       VeD   VP                  \        P$                  8X  d%   VP"                  R8X  d   VP)                  R	4       RpV'       g   V'       d
   VR	,          MRpM{VP                  \        P$                  8X  d]   VP"                  R8X  d"   V'       d   VP'                  VR	,          4       M*VP"                  R8X  d   V'       d   VP)                  R	4      pVV,          V,           V8  g   EKi  Wn,          V,           V8*  p M	  V'       d   V'       d
   VR	,          # V'       d   V# V'       d
   VR	,          # V'       d   V# V'       d
   VR	,          # R# u up	i )
aN  Get the token at a given cursor

Used for introspection.

Function calls are prioritized, so the token for the callable will be returned
if the cursor is anywhere inside the call.

Parameters
----------
cell : str
    A block of Python code
cursor_pos : int
    The location of the cursor in the block where the token should be found
NFr0   T.=()r1   )r!   r   r#   r	   zip	itertoolspairwiser   r   r   rA   	enumeraterB   r   r    NAMEr   r   OPr5   pop)r=   r>   names
call_namesclosing_call_namemost_recent_outer_nameoffsetsintersects_with_cursorcur_token_is_nametupr:   prev_toktoknext_tok
start_line	start_colend_lineend_colrE   linenor   rD   s   &&                    r   token_at_cursorre   b   s    EJ$()-!fG".x~/F/FG"GsG  " %(	++FdVO<&!/3 !$		
GG'a<w&HH''-E )%a @(&-fqj&9CI&EGFO !A !$I
*  #		X]] : V V9SXXCV?VVVNNhkk1MMS(',Ryy#((;b	SXX&$NNhkk1MMS( 		"$)!6;r&YY(++%xx35!!%),SZ$.NN2$6!8w&3 &-%89%D
%R"k&n 3Ry 
  	"~	 &%	Ry _"s   M)N)r)   )__doc__
__future__r   rO   r    ior   keywordr   r   typingr   collections.abcr   r	   r!   r;   rG   re   r   r   r   <module>rl      sJ     #       %J >Df fr   