
    ^h                    X    S r SSKJr  SSKJr  SSKJrJr  SSKJ	r	  S/r
 " S S\5      rg	)
z#
Validator for a regular language.
    )annotations)Document)ValidationError	Validator   )_CompiledGrammarGrammarValidatorc                  8    \ rS rSrSr      SS jrSS jrSrg)	r	      aB  
Validator which can be used for validation according to variables in
the grammar. Each variable can have its own validator.

:param compiled_grammar: `GrammarCompleter` instance.
:param validators: `dict` mapping variable names of the grammar to the
                   `Validator` instances to be used for each variable.
c                    Xl         X l        g )Ncompiled_grammar
validators)selfr   r   s      m/home/james-whalen/.local/lib/python3.13/site-packages/prompt_toolkit/contrib/regular_languages/validation.py__init__GrammarValidator.__init__   s     !1$    c                J   U R                   R                  UR                  5      nU(       a  UR                  5        H  nU R                  R                  UR                  5      nU(       d  M1  U R                   R                  UR                  UR                  5      n[        U[        U5      5      n UR                  U5        M     g [        [        UR                  5      SS9e! [         a1  n[        UR                  UR                  -   UR                  S9UeS nAff = f)N)cursor_positionmessagezInvalid command)r   matchtext	variablesr   getvarnameunescapevaluer   lenvalidater   startr   r   )r   documentmv	validatorunwrapped_textinner_documentes           r   r    GrammarValidator.validate!   s     !!''6[[] OO//		:	9%)%:%:%C%CAIIqww%WN &.nc.>Q%RN!!**>: #$ " #HMM 2<M  + !-,-GGa6G6G,G$%II  !!!s   4C''
D"1,DD"r   N)r   r   r   zdict[str, Validator]returnNone)r"   r   r*   r+   )__name__
__module____qualname____firstlineno____doc__r   r    __static_attributes__ r   r   r	   r	      s)    % 0%>R%	%r   N)r0   
__future__r   prompt_toolkit.documentr   prompt_toolkit.validationr   r   compilerr   __all__r	   r2   r   r   <module>r8      s0    # , @ & 
+y +r   