U
    ¸mœd¬  ã                   @   sà   U d dl Z d dlZd dlmZ d dlmZmZmZmZm	Z	m
Z
 ddlmZ eG dd„ dƒƒZG dd	„ d	eƒZd
ddddde dej¡dddde dej¡e ejej ejejB ¡ddddddddœZded< G d d!„ d!ƒZdS )"é    N)Ú	dataclass)ÚDictÚIteratorÚNoReturnÚOptionalÚTupleÚUnioné   )Ú	Specifierc                   @   s&   e Zd ZU eed< eed< eed< dS )ÚTokenÚnameÚtextÚpositionN)Ú__name__Ú
__module__Ú__qualname__ÚstrÚ__annotations__Úint© r   r   úM/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/packaging/_tokenizer.pyr   	   s   
r   c                       sB   e Zd ZdZeeeeef ddœ‡ fdd„Zedœdd„Z‡  Z	S )	ÚParserSyntaxErrorz7The provided source text could not be parsed correctly.N)ÚmessageÚsourceÚspanÚreturnc                   s    || _ || _|| _tƒ  ¡  d S )N)r   r   r   ÚsuperÚ__init__)Úselfr   r   r   ©Ú	__class__r   r   r      s    zParserSyntaxError.__init__©r   c                 C   s>   d| j d  d| j d | j d    d }d | j| j|g¡S )Nú r   ú~r	   ú^z
    )r   Újoinr   r   )r   Úmarkerr   r   r   Ú__str__    s    *zParserSyntaxError.__str__)
r   r   r   Ú__doc__r   r   r   r   r'   Ú__classcell__r   r   r   r   r      s   
úr   z\(z\)z\[z\]ú;ú,zk
            (
                ('[^']*')
                |
                ("[^"]*")
            )
        z(===|==|~=|!=|<=|>=|<|>)z\b(or|and)\bz\bin\bz\bnot\ba‡  
            \b(
                python_version
                |python_full_version
                |os[._]name
                |sys[._]platform
                |platform_(release|system)
                |platform[._](version|machine|python_implementation)
                |python_implementation
                |implementation_(name|version)
                |extra
            )\b
        z\@z[^ \t]+z\b[a-zA-Z0-9][a-zA-Z0-9._-]*\bz\.\*z\+[a-z0-9]+(?:[-_\.][a-z0-9]+)*z[ \t]+ú$)ZLEFT_PARENTHESISZRIGHT_PARENTHESISZLEFT_BRACKETZRIGHT_BRACKETÚ	SEMICOLONÚCOMMAZQUOTED_STRINGÚOPÚBOOLOPÚINZNOTÚVARIABLEZ	SPECIFIERÚATÚURLÚ
IDENTIFIERZVERSION_PREFIX_TRAILZVERSION_LOCAL_LABEL_TRAILZWSZENDú&Dict[str, Union[str, re.Pattern[str]]]ÚDEFAULT_RULESc                   @   s¬   e Zd ZdZedddœdd„Zeddœdd	„Zd
dœeeedœdd„Zeee	dœdd„Z
e	dœdd„Zdddœeee ee edœdd„Zejeeeed dœdd„ƒZdS )Ú	Tokenizerz„Context-sensitive token parsing.

    Provides methods to examine the input stream to check whether the next token
    matches.
    r6   N)r   Úrulesr   c                C   s*   || _ dd„ | ¡ D ƒ| _d | _d| _d S )Nc                 S   s   i | ]\}}|t  |¡“qS r   )ÚreÚcompile)Ú.0r   Úpatternr   r   r   Ú
<dictcomp>f   s     z&Tokenizer.__init__.<locals>.<dictcomp>r   )r   Úitemsr9   Ú
next_tokenr   )r   r   r9   r   r   r   r   _   s    ÿzTokenizer.__init__)r   r   c                 C   s   |   |¡r|  ¡  dS )z8Move beyond provided token name, if at current position.N)ÚcheckÚread)r   r   r   r   r   Úconsumel   s    
zTokenizer.consumeF)Úpeek)r   rD   r   c                C   sz   | j dks td|›d| j ›�ƒ‚|| jks8td|›�ƒ‚| j| }| | j| j¡}|dkr^dS |svt||d | jƒ| _ dS )zÿCheck 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)r@   ÚAssertionErrorr9   Úmatchr   r   r   )r   r   rD   Z
expressionrF   r   r   r   rA   q   s    ÿþ
zTokenizer.check)r   Ú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 )rA   Úraise_syntax_errorrB   )r   r   rG   r   r   r   Úexpect†   s    
zTokenizer.expectr!   c                 C   s0   | j }|dk	st‚|  jt|jƒ7  _d| _ |S )z%Consume the next token and return it.N)r@   rE   r   Úlenr   )r   Útokenr   r   r   rB   �   s
    zTokenizer.read)Ú
span_startÚspan_end)r   rL   rM   r   c                C   s8   |dkr| j n||dkr| j n|f}t|| j|d�‚dS )z.Raise ParserSyntaxError at the given position.N)r   r   )r   r   r   )r   r   rL   rM   r   r   r   r   rH   ™   s    	þýzTokenizer.raise_syntax_error)Ú
open_tokenÚclose_tokenÚaroundr   c                c   sf   |   |¡r| j}|  ¡  nd }d V  |d kr0d S |   |¡sZ| jd|› d|› d|› �|d� |  ¡  d S )NzExpected matching z for z, after )rL   )rA   r   rB   rH   )r   rN   rO   rP   Zopen_positionr   r   r   Úenclosing_tokens«   s    


þzTokenizer.enclosing_tokens)r   r   r   r(   r   r   rC   ÚboolrA   r   rI   rB   r   r   r   rH   Ú
contextlibÚcontextmanagerr   rQ   r   r   r   r   r8   X   s.   û	ûú  þr8   )rS   r:   Údataclassesr   Útypingr   r   r   r   r   r   Ú
specifiersr
   r   Ú	Exceptionr   r;   ÚVERBOSEZ_operator_regex_strZ_version_regex_strÚ
IGNORECASEr7   r   r8   r   r   r   r   Ú<module>   sN     ø
ò

þÑ3