o
    )ri-                     @  s  U d dl mZ d dlZd dlZd dlmZ d dlmZmZm	Z	 ddl
mZ eG dd dZG d	d
 d
eZi deddeddeddeddeddeddedejdeddeddedded d!ed"ejd#eejej ejejB d$ed%d&ed'd(ed)d*ed+ed,ed-ed.d/Zd0ed1< G d2d3 d3ZdS )4    )annotationsN)	dataclass)	GeneratorMappingNoReturn   )	Specifierc                   @  s&   e Zd ZU ded< ded< ded< dS )TokenstrnametextintpositionN)__name__
__module____qualname____annotations__ r   r   S/home/air/biblejyuku/back/venv/lib/python3.10/site-packages/packaging/_tokenizer.pyr	      s   
 r	   c                      s,   e Zd ZdZd fd	d
ZdddZ  ZS )ParserSyntaxErrorz7The provided source text could not be parsed correctly.messager
   sourcespantuple[int, int]returnNonec                  s    || _ || _|| _t   d S )N)r   r   r   super__init__)selfr   r   r   	__class__r   r   r      s   zParserSyntaxError.__init__c                 C  sB   d| j d  d| j d | j d    d }| j d| j d| S )N r   ~r   ^z
    )r   r   r   )r   markerr   r   r   __str__"   s   *zParserSyntaxError.__str__)r   r
   r   r
   r   r   r   r   )r   r
   )r   r   r   __doc__r   r%   __classcell__r   r   r   r   r      s    r   LEFT_PARENTHESISz\(RIGHT_PARENTHESISz\)LEFT_BRACKETz\[RIGHT_BRACKETz\]	SEMICOLON;COMMA,QUOTED_STRINGzk
            (
                ('[^']*')
                |
                ("[^"]*")
            )
        OPz(===|==|~=|!=|<=|>=|<|>)BOOLOPz\b(or|and)\bINz\bin\bNOTz\bnot\bVARIABLEa  
            \b(
                python_version
                |python_full_version
                |os[._]name
                |sys[._]platform
                |platform_(release|system)
                |platform[._](version|machine|python_implementation)
                |python_implementation
                |implementation_(name|version)
                |extras?
                |dependency_groups
            )\b
        	SPECIFIERATz\@URLz[^ \t]+
IDENTIFIERz\b[a-zA-Z0-9][a-zA-Z0-9._-]*\bVERSION_PREFIX_TRAILz\.\*z\+[a-z0-9]+(?:[-_\.][a-z0-9]+)*z[ \t]+$)VERSION_LOCAL_LABEL_TRAILWSENDzdict[str, re.Pattern[str]]DEFAULT_RULESc                   @  sj   e Zd ZdZd(dd	Zd)ddZddd*ddZd+ddZd,ddZdddd-d d!Z	e
jd.d&d'ZdS )/	TokenizerzContext-sensitive token parsing.

    Provides methods to examine the input stream to check whether the next token
    matches.
    r   r
   rulesMapping[str, re.Pattern[str]]r   r   c                C  s   || _ || _d | _d| _d S )Nr   )r   rA   
next_tokenr   )r   r   rA   r   r   r   r   b   s   
zTokenizer.__init__r   c                 C  s   |  |r|   dS dS )z8Move beyond provided token name, if at current position.N)checkread)r   r   r   r   r   consumem   s   
zTokenizer.consumeF)peekrG   boolc                C  sz   | j du sJ d|d| j || jv sJ d|| j| }|| j| j}|du r/dS |s;t||d | j| _ dS )zCheck whether the next token has the provided name.

        By default, if the check succeeds, the token *must* be read before
        another check. If `peek` is set to `True`, the token is not loaded and
        would need to be checked again.
        NzCannot check for z, already have zUnknown token name: Fr   T)rC   rA   matchr   r   r	   )r   r   rG   
expressionrI   r   r   r   rD   r   s   
zTokenizer.checkexpectedr	   c                C  s"   |  |s| d| |  S )zsExpect a certain token name next, failing with a syntax error otherwise.

        The token is *not* read.
        z	Expected )rD   raise_syntax_errorrE   )r   r   rK   r   r   r   expect   s   
zTokenizer.expectc                 C  s0   | j }|dus	J |  jt|j7  _d| _ |S )z%Consume the next token and return it.N)rC   r   lenr   )r   tokenr   r   r   rE      s
   zTokenizer.readN)
span_startspan_endr   rP   
int | NonerQ   r   c                C  s4   |du r| j n||du r| j n|f}t|| j|d)z.Raise ParserSyntaxError at the given position.N)r   r   )r   r   r   )r   r   rP   rQ   r   r   r   r   rL      s   	zTokenizer.raise_syntax_error
open_tokenclose_tokenaroundGenerator[None, None, None]c                c  sh    |  |r| j}|   nd }d V  |d u rd S |  |s.| jd| d| d| |d |   d S )NzExpected matching z for z, after )rP   )rD   r   rE   rL   )r   rS   rT   rU   open_positionr   r   r   enclosing_tokens   s   


zTokenizer.enclosing_tokens)r   r
   rA   rB   r   r   )r   r
   r   r   )r   r
   rG   rH   r   rH   )r   r
   rK   r
   r   r	   )r   r	   )r   r
   rP   rR   rQ   rR   r   r   )rS   r
   rT   r
   rU   r
   r   rV   )r   r   r   r&   r   rF   rD   rM   rE   rL   
contextlibcontextmanagerrX   r   r   r   r   r@   [   s    



	r@   )
__future__r   rY   redataclassesr   typingr   r   r   
specifiersr   r	   	Exceptionr   compileVERBOSE_operator_regex_str_version_regex_str
IGNORECASEr?   r   r@   r   r   r   r   <module>   st    









&


*
+
,
-.4