B
    't\,                 @   st   d Z ddlmZ ddlmZmZ ddlmZmZ dddgZ	G dd deee
ZG d	d deZG d
d deZdS )z)
Base classes for prompt_toolkit lexers.
    )unicode_literals)ABCMetaabstractmethod)with_metaclass	text_typeLexerSimpleLexerDynamicLexerc               @   s$   e Zd ZdZedd Zdd ZdS )r   z$
    Base class for all lexers.
    c             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 )selfdocumentr
   r
   9lib/python3.7/site-packages/prompt_toolkit/lexers/base.pylex_document   s    	zLexer.lex_documentc             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   r
   r
   r
   r   r      s   c               @   s"   e Zd ZdZdddZ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.
     c             C   s   t |tst|| _d S )N)
isinstancer   AssertionErrorstyle)r   r   r
   r
   r   __init__-   s    zSimpleLexer.__init__c                s   |j   fdd}|S )Nc                s*   yj  |  fgS  tk
r$   g S X dS )z' Return the tokens for the given line. N)r   
IndexError)lineno)linesr   r
   r   get_line4   s    z*SimpleLexer.lex_document.<locals>.get_line)r   )r   r   r   r
   )r   r   r   r   1   s    zSimpleLexer.lex_documentN)r   )r   r   r   r   r   r   r
   r
   r
   r   r   &   s   
c               @   s(   e Zd ZdZdd Zdd Z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.
    c             C   s   || _ t | _d S )N)	get_lexerr   _dummy)r   r   r
   r
   r   r   C   s    zDynamicLexer.__init__c             C   s&   |   p| j}t|tst||S )N)r   r   r   r   r   r   )r   r   lexerr
   r
   r   r   G   s    zDynamicLexer.lex_documentc             C   s   |   p| j}t|S )N)r   r   r   )r   r    r
   r
   r   r   L   s    zDynamicLexer.invalidation_hashN)r   r   r   r   r   r   r   r
   r
   r
   r   r	   =   s   N)r   Z
__future__r   abcr   r   Zsixr   r   __all__objectr   r   r	   r
   r
   r
   r   <module>   s   