o
    Df.	                     @  s   d Z ddlmZ ddlmZmZ ddlmZmZ ddl	m
Z
 ddlmZ g d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.
    )annotations)ABCMetaabstractmethod)CallableHashable)Document)StyleAndTextTuples)LexerSimpleLexerDynamicLexerc                   @  s(   e Zd ZdZedddZdd	d
ZdS )r	   z$
    Base class for all lexers.
    documentr   return#Callable[[int], StyleAndTextTuples]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 )selfr   r   r   S/home/ubuntu/webapp/venv/lib/python3.10/site-packages/prompt_toolkit/lexers/base.pylex_document   s    zLexer.lex_documentr   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r   r   r   r   r   r   )__name__
__module____qualname____doc__r   r   r   r   r   r   r   r	      s
    
r	   )	metaclassc                   @  s&   e Zd ZdZddddZ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.
     stylestrr   Nonec                 C  s
   || _ d S N)r   )r   r   r   r   r   __init__4   s   
zSimpleLexer.__init__r   r   r   c                   s   |j  d fdd}|S )Nlinenointr   r   c                   s*   z	j  |  fgW S  ty   g  Y S w )z%Return the tokens for the given line.)r   
IndexError)r"   linesr   r   r   get_line:   s
   z*SimpleLexer.lex_document.<locals>.get_line)r"   r#   r   r   )r&   )r   r   r'   r   r%   r   r   7   s   zSimpleLexer.lex_documentN)r   )r   r   r   r   r   )r   r   r   r   r!   r   r   r   r   r   r
   ,   s    r
   c                   @  s.   e Zd ZdZdddZdddZ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.
    	get_lexerCallable[[], Lexer | None]r   r   c                 C  s   || _ t | _d S r    )r(   r
   _dummy)r   r(   r   r   r   r!   K   s   zDynamicLexer.__init__r   r   r   c                 C  s   |   p| j}||S r    )r(   r*   r   )r   r   lexerr   r   r   r   O   s   
zDynamicLexer.lex_documentr   c                 C  s   |   p| j}t|S r    )r(   r*   r   )r   r+   r   r   r   r   S   s   zDynamicLexer.invalidation_hashN)r(   r)   r   r   r   r   )r   r   r   r   r!   r   r   r   r   r   r   r   D   s
    

r   N)r   
__future__r   abcr   r   typingr   r   prompt_toolkit.documentr   "prompt_toolkit.formatted_text.baser   __all__r	   r
   r   r   r   r   r   <module>   s    