U
    cc	                     @   s   d Z ddlmZmZ ddlmZmZmZ ddlm	Z	 ddl
mZ dddgZG d	d ded
ZG dd deZG dd deZdS )z)
Base classes for prompt_toolkit lexers.
    )ABCMetaabstractmethod)CallableHashableOptional)Document)StyleAndTextTuplesLexerSimpleLexerDynamicLexerc                   @   s<   e Zd ZdZeeeegef dddZ	e
dddZdS )	r	   z$
    Base class for all lexers.
    documentreturnc                 C   s   dS )aT  
        Takes a :class:`~prompt_toolkit.document.Document` and returns a
        callable that takes a line number and returns a list of
        ``(style_str, text)`` tuples for that line.

        XXX: Note that in the past, this was supposed to return a list
             of ``(Token, text)`` tuples, just like a Pygments lexer.
        N )selfr   r   r   T/var/www/html/project/venv/lib/python3.8/site-packages/prompt_toolkit/lexers/base.pylex_document   s    zLexer.lex_documentr   c                 C   s   t | S )zz
        When this changes, `lex_document` could give a different output.
        (Only used for `DynamicLexer`.)
        )id)r   r   r   r   invalidation_hash!   s    zLexer.invalidation_hashN)__name__
__module____qualname____doc__r   r   r   intr   r   r   r   r   r   r   r   r	      s   
)	metaclassc                   @   s<   e Zd ZdZd
eddddZeeege	f ddd	Z
dS )r
   z
    Lexer that doesn't do any tokenizing and returns the whole input as one
    token.

    :param style: The style string for this lexer.
     N)styler   c                 C   s
   || _ d S N)r   )r   r   r   r   r   __init__1   s    zSimpleLexer.__init__r   c                    s    |j  ttd fdd}|S )N)linenor   c                    s0   zj  |  fgW S  tk
r*   g  Y S X dS )z%Return the tokens for the given line.N)r   
IndexError)r    linesr   r   r   get_line7   s    z*SimpleLexer.lex_document.<locals>.get_line)r#   r   r   )r   r   r$   r   r"   r   r   4   s    zSimpleLexer.lex_document)r   )r   r   r   r   strr   r   r   r   r   r   r   r   r   r   r
   )   s   c                   @   sT   e Zd ZdZeg ee f ddddZeee	ge
f dddZed	d
dZdS )r   z
    Lexer class that can dynamically returns any Lexer.

    :param get_lexer: Callable that returns a :class:`.Lexer` instance.
    N)	get_lexerr   c                 C   s   || _ t | _d S r   )r&   r
   _dummy)r   r&   r   r   r   r   H   s    zDynamicLexer.__init__r   c                 C   s   |   p| j}||S r   )r&   r'   r   )r   r   lexerr   r   r   r   L   s    zDynamicLexer.lex_documentr   c                 C   s   |   p| j}t|S r   )r&   r'   r   )r   r(   r   r   r   r   P   s    zDynamicLexer.invalidation_hash)r   r   r   r   r   r   r	   r   r   r   r   r   r   r   r   r   r   r   r   A   s   N)r   abcr   r   typingr   r   r   Zprompt_toolkit.documentr   Z"prompt_toolkit.formatted_text.baser   __all__r	   r
   r   r   r   r   r   <module>   s   