← Back
Editing: base.cpython-311.pyc
� �Ïc � � � d Z ddlmZmZ ddlmZmZmZ ddlm Z ddl mZ g d�Z G d� de� � � Z G d � de � � Z G d� d e � � ZdS )z) Base classes for prompt_toolkit lexers. � )�ABCMeta�abstractmethod)�Callable�Hashable�Optional)�Document)�StyleAndTextTuples)�Lexer�SimpleLexer�DynamicLexerc �P � e Zd ZdZededeegef fd�� � Z de fd�ZdS )r z$ Base class for all lexers. �document�returnc � � dS )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 s �</usr/lib/python3/dist-packages/prompt_toolkit/lexers/base.py�lex_documentzLexer.lex_document s � � � � c � � t | � � S )zz When this changes, `lex_document` could give a different output. (Only used for `DynamicLexer`.) )�id)r s r �invalidation_hashzLexer.invalidation_hash! s � � �$�x�x�r N)�__name__� __module__�__qualname__�__doc__r r r �intr r r r r r r r r st � � � � � �� � ��X� �(�C�5�BT�;T�2U� � � � �^���8� � � � � � r r )� metaclassc �F � e Zd ZdZd deddfd�Zdedeege f fd�Z dS ) 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. � �styler Nc � � || _ d S �N)r! )r r! s r �__init__zSimpleLexer.__init__1 s � ��� � � r r c �B � �� |j �dt dt f�� fd�}|S )N�linenor c �J �� �j �| fgS # t $ r g cY S w xY w)z%Return the tokens for the given line.)r! � IndexError)r&