
    i>                        S SK r S SKrS SKJr  S SKJrJrJrJrJ	r	J
r
JrJrJrJr  S SKJr  SSKJr  \(       a  SSKJr   S SKJr  S S	KJr  S S
KJr   " S S\5      rg! \ a&    \" S\ R:                  S9  \ R<                  " S5         N7f = f)    N)zip_longest)
TYPE_CHECKINGAnyCallableDict	GeneratorListOptionalSetTupleUnion)TerminalNode   )InterpolationResolutionError)Node)OmegaConfGrammarLexer)OmegaConfGrammarParser)OmegaConfGrammarParserVisitorzYError importing OmegaConf's generated parsers, run `python setup.py antlr` to regenerate.)filec            
         ^  \ rS rSrS\\\\\      /\S   4   S\S\	4   S\\\      S\
\	\	4   4U 4S jjrS	\\	   S
\	S\\	   4S jrS\\	   4S jrS\R                   S\4S jrS\R$                  S\	4S jrS\R(                  S\	4S jrS\R,                  S\
\	\	4   4S jrS\R0                  S\	4S jrS\R4                  S\	4S jrS\R8                  S\S   4S jrS\R<                  S\	4S jrS\R@                  S\!\	\	4   4S jr"S\RF                  S\\	   4S jr$S\RJ                  S\	4S jr&S\RN                  S\4S jr(S\RR                  S\4S jr*S\RV                  S\,\	SS4   4S jr-S\R\                  S\	4S jr/S\R`                  S\	4S jr1S\2\RJ                  \R(                  4   S\	4S  jr3S!\\2\4\R4                  4      S\4S" jr5S#r6U =r7$ )$GrammarVisitor'   node_interpolation_callbackr   resolver_interpolation_callback.memokwc                 J   > [         TU ]  " S0 UD6  Xl        X l        X0l        g)a  
Constructor.

:param node_interpolation_callback: Callback function that is called when
    needing to resolve a node interpolation. This function should take a single
    string input which is the key's dot path (ex: `"foo.bar"`).

:param resolver_interpolation_callback: Callback function that is called when
    needing to resolve a resolver interpolation. This function should accept
    three keyword arguments: `name` (str, the name of the resolver),
    `args` (tuple, the inputs to the resolver), and `args_str` (tuple,
    the string representation of the inputs to the resolver).

:param kw: Additional keyword arguments to be forwarded to parent class.
N )super__init__r   r   r   )selfr   r   r   r   	__class__s        X/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/omegaconf/grammar_visitor.pyr    GrammarVisitor.__init__(   s&    2 	2+F(/N,	    	aggregate
nextResultreturnc                     [         eNNotImplementedError)r!   r&   r'   s      r#   aggregateResultGrammarVisitor.aggregateResultF   s    !!r%   c                     [         er*   r+   )r!   s    r#   defaultResultGrammarVisitor.defaultResultI   s    !!r%   ctxc           
         SSK Jn  UR                  5       S:X  d   eUR                  S5      n[	        U[
        R                  5      (       ah  U" U R                  U5      5      n[	        U[        5      (       d:  [        SU S[        U5       SUR                  S5      R                  5        35      eU$ [	        U[        5      (       a)  [	        UR                  R                  [        5      (       d   eUR                  R                  $ )Nr   
_get_valuer   zrThe following interpolation is used to denote a config key and thus should return a string, but instead returned `z` of type `z`: )_utilsr5   getChildCountgetChild
isinstancer   InterpolationContextvisitInterpolationstrr   typegetTextr   symboltext)r!   r2   r5   childress        r#   visitConfigKeyGrammarVisitor.visitConfigKeyM   s    &   "a'''Qe3HHIIT44U;<Cc3''2JJM O!#YKs3<<?+B+B+D*EG 
 Je\22z!!38 8   <<$$$r%   c                 n    UR                  5       S:X  d   eU R                  UR                  S5      5      $ N   r   r7   visitr8   r!   r2   s     r#   visitConfigValueGrammarVisitor.visitConfigValueb   0      "a'''zz#,,q/**r%   c                 $    U R                  U5      $ r*   _createPrimitiverJ   s     r#   visitDictKeyGrammarVisitor.visitDictKeyg       $$S))r%   c                    ^ ^ TR                  5       S:  d   e[        UU 4S j[        STR                  5       S-
  S5       5       5      $ )NrG   c              3   d   >#    U  H%  nTR                  TR                  U5      5      v   M'     g 7fr*   )visitDictKeyValuePairr8   ).0ir2   r!   s     r#   	<genexpr>4GrammarVisitor.visitDictContainer.<locals>.<genexpr>o   s.      
9 &&s||A779s   -0r   )r7   dictrangerJ   s   ``r#   visitDictContainer!GrammarVisitor.visitDictContainerj   sM       "a''' 
1c//1A5q9
 
 	
r%   c                 n    UR                  5       S:X  d   eU R                  UR                  S5      5      $ Nr   r   rH   rJ   s     r#   visitElementGrammarVisitor.visitElementt   rM   r%   c                 n    UR                  5       S:X  d   eU R                  UR                  S5      5      $ r`   rH   rJ   s     r#   r;   !GrammarVisitor.visitInterpolationy   s2       "a'''zz#,,q/**r%   c                    UR                  5       S:  d   e/ nUR                  5        H  n[        U[        5      (       a  UR                  nUR
                  [        R                  [        R                  [        R                  4;   a  UR                  UR                  5        M~  UR
                  [        R                  [        R                  4;   d   eM  [        U[        R                  5      (       d   eUR                  U R!                  U5      5        M     SR#                  U5      nU R%                  XPR&                  5      $ )N    )r7   getChildrenr9   r   r?   r=   r   DOTBRACKET_OPENBRACKET_CLOSEappendr@   
INTER_OPENINTER_CLOSEr   ConfigKeyContextrC   joinr   r   )r!   r2   inter_key_tokensrA   s	inter_keys         r#   visitInterpolationNode%GrammarVisitor.visitInterpolationNode   s      "a'''__&E%..LL66)--)66)77 
 %++AFF366-88-99&   
 "%)?)P)PQQQQ ''(;(;E(BC! '$ GG,-	//	99EEr%   c                 ,   SUR                  5       s=::  a  S::  d   e   eU R                  UR                  S5      5      nUR                  S5      n/ n/ n[        U[        5      (       a+  UR
                  R                  [        R                  :X  d   eO][        U[        R                  5      (       d   eU R                  U5       H'  u  pgUR                  U5        UR                  U5        M)     U R                  U[        U5      [        U5      S9$ )N      r   rf   )nameargsargs_str)r7   rI   r8   r9   r   r?   r=   r   BRACE_CLOSEr   SequenceContextvisitSequencerl   r   tuple)r!   r2   resolver_name	maybe_seqrz   r{   valtxts           r#   visitInterpolationResolver)GrammarVisitor.visitInterpolationResolver   s    
 C%%',1,,,,,

3<<?3LLO	i..##((,A,M,MMMMi)?)O)OPPPP ..y9C $ : 33t8_ 4 
 	
r%   c                 l   SSK Jn  UR                  5       S:X  d   eU R                  UR	                  S5      5      nUR	                  S5      n[        U[        5      (       a(  UR                  R                  [        R                  :X  d   eU" U R                  UR	                  S5      5      5      nX54$ )Nr   r4   rf   r   rG   )r6   r5   r7   rI   r8   r9   r   r?   r=   r   COLONra   )r!   r2   r5   keycolonvalues         r#   rV   $GrammarVisitor.visitDictKeyValuePair   s     	'  "a'''jja)Qul++!!%:%@%@@	
A 4,,S\\!_=>zr%   c                     UR                  5       S;   d   eUR                  5       S:X  a  / $ UR                  S5      n[        U[        R                  5      (       d   e[        S U R                  U5       5       5      $ )NrG   rf   rG   r   c              3   *   #    U  H	  u  pUv   M     g 7fr*   r   )rW   r   _s      r#   rY   4GrammarVisitor.visitListContainer.<locals>.<genexpr>   s     C&BFCC&Bs   )r7   r8   r9   r   r}   listr~   )r!   r2   sequences      r#   visitListContainer!GrammarVisitor.visitListContainer   st       "f,,,!#I<<?($:$J$JKKKKCd&8&8&BCCCr%   c                 $    U R                  U5      $ r*   rO   rJ   s     r#   visitPrimitiveGrammarVisitor.visitPrimitive   rS   r%   c                     UR                  5       nUS;   d   eUS:X  a)  [        U R                  UR                  S5      5      5      $ S$ )Nr   rf   r   rg   )r7   r<   rI   r8   )r!   r2   ns      r#   visitQuotedValueGrammarVisitor.visitQuotedValue   sC    F{{346s4::cll1o./ArAr%   c                    SSK Jn  UR                  5       S:  d   e/ n[        UR	                  5       5      S S S2    H  n[        U[        5      (       aQ  UR                  R                  [        R                  :X  d   eUR                  UR                  R                  5        Mi  [        U[        R                  5      (       d   eU" U R                  U5      5      n[        U[         5      (       d+  [#        SUR%                  5        SU S[        U5       35      eUR                  U5        M     SR'                  U5      $ )Nr   r4   rG   z?The name of a resolver must be a string, but the interpolation z resolved to `z` which is of type .)r6   r5   r7   r   rh   r9   r   r?   r=   r   IDrl   r@   r   r:   r;   r<   r   r>   rp   )r!   r2   r5   itemsrA   items         r#   visitResolverName GrammarVisitor.visitResolverName   s   &   "a'''#//+,SqS1E%..||((,A,D,DDDDU\\../!%)?)T)TUUUU!$"9"9%"@A!$,,6Y ==?+>$?R:,( 
 T" 2 xxr%   Nc              #     ^#    SSK Jn  TR                  5       S:  d   eSU4S jjnSnTR                  5        H  n[	        U[
        R                  5      (       a-  U" U R                  U5      5      UR                  5       4v   SnMO  [	        U[        5      (       a(  UR                  R                  [        R                  :X  d   eU(       a  U" 5         Sv   M  SnM     U(       a  U" 5         Sv   g g 7f)Nr   r4   c                  `   > TR                  5       n [        R                  " SU  S3[        S9  g )NzIn the sequence `z` some elements are missing: please replace them with empty quoted strings. See https://github.com/omry/omegaconf/issues/572 for details.)category)r>   warningswarnUserWarning)r   r2   s    r#   empty_str_warning7GrammarVisitor.visitSequence.<locals>.empty_str_warning   s2    ++-CMM#C5 )P Q %	r%   TF)rg   rg   )r(   N)r6   r5   r7   rh   r9   r   ElementContextra   r>   r   r?   r=   r   COMMA)r!   r2   r5   r   is_previous_commarA   s    `    r#   r~   GrammarVisitor.visitSequence   s      	'   "a'''	 !__&E%!7!F!FGG
 !!2!25!9:EMMOKK$)! ul33))-B-H-HHI %%' L(,%# '$ L s   C3C6c                 n    UR                  5       S:X  d   eU R                  UR                  S5      5      $ rF   rH   rJ   s     r#   visitSingleElement!GrammarVisitor.visitSingleElement  s2       "a'''zz#,,q/**r%   c                     UR                  5       S:X  aA  UR                  S5      n[        U[        R                  5      (       a  U R                  U5      $ U R                  [        UR                  5       5      5      $ r`   )	r7   r8   r9   r   r:   r;   	_unescaper   rh   )r!   r2   cs      r#   	visitTextGrammarVisitor.visitText#  sd     !#QA!3HHII..q11 ~~d3??#4566r%   c                 *   UR                  5       S:X  Ga  UR                  S5      n[        U[        R                  5      (       a  U R                  U5      $ [        U[        5      (       d   eUR                  nUR                  [        R                  [        R                  [        R                  4;   a  UR                  $ UR                  [        R                  :X  a  g UR                  [        R                  :X  a  [!        UR                  5      $ UR                  [        R"                  :X  a  [%        UR                  5      $ UR                  [        R&                  :X  a  UR                  R)                  5       S:H  $ UR                  [        R*                  :X  a  U R-                  U/5      $ UR                  [        R.                  :X  a  [1        S5      e UR                  5       eU R-                  [3        UR5                  5       5      5      $ )Nr   r   truezWS should never be reached)r7   r8   r9   r   r:   r;   r   r?   r=   r   r   UNQUOTED_CHARr   r@   NULLINTintFLOATfloatBOOLlowerESCr   WSAssertionErrorr   rh   )r!   r2   rA   r?   s       r#   rP   GrammarVisitor._createPrimitive/  s    !#LLOE%!7!L!LMM..u55e\2222\\F{{%((%33%++ 
 {{" 5 : :: 5 9 996;;'' 5 ; ;;V[[)) 5 : ::{{((*f44 5 9 99~~ug.. 5 8 88$%ABB%&++%5~~d3??#4566r%   seqc                 <   / n[        XSS 5       GHw  u  p4[        U[        5      (       Ga  UR                  nUR                  [
        R                  :X  a*  UR                  [        UR                  5      S-  S-   * S nOUR                  [
        R                  :X  d}  UR                  [
        R                  :X  a  [        U[        R                  5      (       d@  UR                  [
        R                  :X  a5  Ub  [        U[        R                  5      (       a  UR                  SSS2   nOHUR                  nO;[        U[        R                  5      (       d   e[        U R                  U5      5      nUR!                  U5        GMz     SR#                  U5      $ )a  
Concatenate all symbols / interpolations in `seq`, unescaping symbols as needed.

Interpolations are resolved and cast to string *WITHOUT* escaping their result
(it is assumed that whatever escaping is required was already handled during the
resolving of the interpolation).
r   NrG   rg   )r   r9   r   r?   r=   r   	ESC_INTERr@   lenr   TOP_ESCr   r:   
QUOTED_ESCr<   r;   rl   rp   )r!   r   chrsnode	next_noderr   r@   s          r#   r   GrammarVisitor._unescapeU  sS    *3AB8OD$--KK662<<< 66CK1$4q$8"9";<D FF3777 "7"?"??&%'='R'R  "7"B"BB%-) )+A+V+V    66!$Q$<D66D!$(>(S(STTTT422489KKK  9N wwt}r%   )r   r   r   )8__name__
__module____qualname____firstlineno__r   r<   r
   r   r   r   r   r    r	   r-   r0   r   ro   rC   ConfigValueContextrK   DictKeyContextrQ   DictContainerContextr]   r   ra   r:   r;   InterpolationNodeContextrt   InterpolationResolverContextr   DictKeyValuePairContextr   rV   ListContainerContextr   PrimitiveContextr   QuotedValueContextr   ResolverNameContextr   r}   r   r~   SingleElementContextr   TextContextr   r   rP   r   r   __static_attributes____classcell__)r"   s   @r#   r   r   '   s   %-(3s8$%V&
 *2#s(); s3x  38n<"c " "S	 ""tCy "%"8"I"I %c %*+$:$M$M +RU +
* 6 E E *# *
)>>
	c3h
+ 6 E E +# +
+)>>+	+F)BBF	&	FB
)FF
	
2)AA	sCx	D)>>	D	c	D*"8"I"I *c *B$:$M$M BRU B%;%O%O TW ,()99(	3d?	#(T+)>>+	+
73?? 
7C 
7$7"33"113
$7 
$7L3%&<&Q&QQRS3 
3 3r%   r   ) sysr   	itertoolsr   typingr   r   r   r   r   r	   r
   r   r   r   antlr4r   errorsr   baser   +omegaconf.grammar.gen.OmegaConfGrammarLexerr   ,omegaconf.grammar.gen.OmegaConfGrammarParserr   3omegaconf.grammar.gen.OmegaConfGrammarParserVisitorr   ModuleNotFoundErrorprintstderrexitr   r   r%   r#   <module>r      sz    
  !     0QSa2 a  	cZZ HHQKs   A )B
B