o
    ^i                     @   sr  d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ dZdZddlZdd	lmZ d
dl m!Z" dd e#e"D g d Z$["e%e&e&f Z'e%e&e(e'e'e(f Z)i ej*eej+eej,eej-eej.eej/eej0eej1eej2eej3eej4eej5eej6eej7eej8eej9eej:eej;eej<eej=eej>eej?eej@eejAeiZBG dd deCZDdejEde(deejE dejEfddZFd!de(dee dee) fddZGde&de(de'de'de(ddfddZHeId kr5eJejKd
kr$eGeLejKd
 M ZNneGejOM ZNeND ]	ZPeHeP  q-dS dS )"a  Tokenization help for Python programs.

generate_tokens(readline) is a generator that breaks a stream of
text into Python tokens.  It accepts a readline-like method which is called
repeatedly to get the next line of input (or "" for EOF).  It generates
5-tuples with these members:

    the token type (see token.py)
    the token (a string)
    the starting (row, column) indices of the token (a 2-tuple of ints)
    the ending (row, column) indices of the token (a 2-tuple of ints)
    the original line (string)

It is designed to match the working of the Python tokenizer exactly, except
that it produces COMMENT tokens for comments and gives type OP for all
operators

Older entry points
    tokenize_loop(readline, tokeneater)
    tokenize(readline, tokeneater=printtoken)
are the same, except instead of generating tokens, tokeneater is a callback
function to which the 5 fields described above are passed as 5 arguments,
each time a new token is found.    N)Iterator)Optional)Grammar)ASYNCAWAITCOMMENTDEDENT	ENDMARKERFSTRING_ENDFSTRING_MIDDLEFSTRING_STARTINDENTNAMENEWLINENLNUMBEROPSTRINGTSTRING_ENDTSTRING_MIDDLETSTRING_STARTtok_namezKa-Ping Yee <ping@lfw.org>z@GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, Skip Montanaro)	TokenType   )tokenc                 C   s   g | ]
}|d  dkr|qS )r   _ ).0xr   r   \/var/www/html/stock_analysis/be/venv/lib/python3.10/site-packages/blib2to3/pgen2/tokenize.py
<listcomp>A   s    r    )tokenizegenerate_tokens
untokenizec                   @   s   e Zd ZdS )
TokenErrorN)__name__
__module____qualname__r   r   r   r   r$   g   s    r$   r   source
prev_tokenreturnc              
   C   s   | j tjkrV|durV|j tjtjfvrV|| j| j }|dr6t	tj| j| jd | j
| j| j
| jd S |ds@|drVt	tj| j| jd | j
| j| j
| jd S | S )a
  
    Black treats `\\\n` at the end of a line as a 'NL' token, while it
    is ignored as whitespace in the regular Python parser.
    But, only the first one. If there's a `\\\n` following it
    (as in, a \ just by itself on a line), that is not made into NL.
    Nz\
   z\
z\   )typer   
whitespacenlnewlinestart_index	end_index
startswithpytokensToken
start_line	start_col)r   r(   r)   	token_strr   r   r   transform_whitespacej   s8   


	
r9   grammarc              
   c   s   |  d}|dg7 }d\}}d }zt| D ]}t|| |}|j|j}}|jtjkr-q| |j	|j
 }|jtjkrB|dkrB|}q||jd  }|jtjkrj|dv rj|dkrYtnt||j|jf|j|jf|fV  ne|jtjkr|dkr|j|jks|J |j|jd ksJ d	}t|j|jd D ]}	|	d }
t|j ||j|	f|j|
f|fV  qn%t|j}|d u rtd
|jt|j ||j|jf|j|jf|fV  |}qW d S  tjy   td||f tjy } ztdt|j ||fd }~ww )N
 )r   r   r   )asyncawaitr=   z...r+   .zUnknown token type: z&Unexpected EOF in multi-line statementzFailed to parse: )splitr4   r!   r9   r6   r7   r-   r   r.   r1   r2   r0   
identifierr   r   end_lineend_coloprangeTOKEN_TYPE_MAPget
ValueErrorUnexpectedEOFr$   TokenizeErrorr%   )r(   r:   lineslinecolumnr)   r   r8   source_liner7   rC   
token_typeexcr   r   r   r!      sj   






6r!   r-   srow_colerow_colrL   c           	      C   sB   |\}}|\}}t | d| d| d| dt|   d| d S )N,-z:		)printr   )	r-   r   rQ   rR   rL   srowscolerowecolr   r   r   
printtoken   s   2r[   __main__)N)Q__doc__syscollections.abcr   typingr   blib2to3.pgen2.grammarr   blib2to3.pgen2.tokenr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   
__author____credits__r4   r   r<   r   _tokendir__all__tupleintCoordstr	TokenInfoindentdedentr0   r/   comment	semicolonlparenrparenlbracketrbracketlbracerbracecolonrD   rA   numberstringfstring_startfstring_middlefstring_endtstring_starttstring_middletstring_end	endmarkerrF   	Exceptionr$   r5   r9   r!   r[   r%   lenargvopenreadtoken_iteratorstdintokr   r   r   r   <module>   s   T	

 'C

