
    -PhA                       U d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ er.dd	lmZmZ dd
lmZmZmZ ddlmZ ddlmZ eegef         Zded<    ej        e          Z ej        d          Z ej        d          Z  ej        dej!                  Z" ej        d          Z# ej        d          Z$ ej        d          Z% ej        d          Z& ej        dej!                  Z' ej        dej!                  Z( ej        d          Z) ej        dej!                  Z*d:dZ+ G d  d!e,          Z- G d" d#          Z. G d$ d%e.          Z/ G d& d'e/          Z0 G d( d)e.          Z1 G d* d+e/          Z2 G d, d-e/          Z3 G d. d/e/          Z4 G d0 d1e.          Z5 G d2 d3e.          Z6 G d4 d5e,          Z7 G d6 d7e,          Z8 G d8 d9          Z9dS );z2Utility functions common to the C and C++ domains.    )annotationsNdeepcopy)TYPE_CHECKING)nodes)addnodes)logging)CallableSequence)AnyNoReturn	TypeAlias)TextElement)Configr   StringifyTransformz\s+z(@[a-zA-Z0-9_])[a-zA-Z0-9_]*\ba
  
    (   # This 'extends' _anon_identifier_re with the ordinary identifiers,
        # make sure they are in sync.
        (~?\b[a-zA-Z_])  # ordinary identifiers
    |   (@[a-zA-Z0-9_])  # our extension for names of anonymous entities
    )
    [a-zA-Z0-9_]*\b
    )flagsz[1-9][0-9]*(\'[0-9]+)*z0[0-7]*(\'[0-7]+)*z"0[xX][0-9a-fA-F]+(\'[0-9a-fA-F]+)*z0[bB][01]+(\'[01]+)*a%  
    # unsigned and/or (long) long, in any order, but at least one of them
    (
        ([uU]    ([lL]  |  (ll)  |  (LL))?)
        |
        (([lL]  |  (ll)  |  (LL))    [uU]?)
    )\b
    # the ending word boundary is important for distinguishing
    # between suffixes and UDLs in C++
    a  
    [+-]?(
    # decimal
      ([0-9]+(\'[0-9]+)*[eE][+-]?[0-9]+(\'[0-9]+)*)
    | (([0-9]+(\'[0-9]+)*)?\.[0-9]+(\'[0-9]+)*([eE][+-]?[0-9]+(\'[0-9]+)*)?)
    | ([0-9]+(\'[0-9]+)*\.([eE][+-]?[0-9]+(\'[0-9]+)*)?)
    # hex
    | (0[xX][0-9a-fA-F]+(\'[0-9a-fA-F]+)*[pP][+-]?[0-9a-fA-F]+(\'[0-9a-fA-F]+)*)
    | (0[xX]([0-9a-fA-F]+(\'[0-9a-fA-F]+)*)?\.
        [0-9a-fA-F]+(\'[0-9a-fA-F]+)*([pP][+-]?[0-9a-fA-F]+(\'[0-9a-fA-F]+)*)?)
    | (0[xX][0-9a-fA-F]+(\'[0-9a-fA-F]+)*\.([pP][+-]?[0-9a-fA-F]+(\'[0-9a-fA-F]+)*)?)
    )
    z[fFlL]\bz
    ((?:u8)|u|U|L)?
    '(
      (?:[^\\'])
    | (\\(
        (?:['"?\\abfnrtv])
      | (?:[0-7]{1,3})
      | (?:x[0-9a-fA-F]{2})
      | (?:u[0-9a-fA-F]{4})
      | (?:U[0-9a-fA-F]{8})
      ))
    )'
    modestrreturnNonec                2    | dvrt          d| z            d S )N>   udlparammarkNamemarkType
lastIsName
noneIsNamez!Description mode '%s' is invalid.)	Exception)r   s    S/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sphinx/util/cfamily.pyverify_description_moder    \   s+    WWW;dBCCC XW    c                      e Zd ZdS )NoOldIdErrorN__name__
__module____qualname__ r!   r   r#   r#   a   s        Dr!   r#   c                  F    e Zd ZddZddZdd	ZddZddZddZddZ	dS )ASTBaseBaseotherobjectr   boolc                    t          |           t          |          urt          S 	 | j        |j        k    S # t          $ r Y dS w xY w)NF)typeNotImplemented__dict__AttributeErrorselfr+   s     r   __eq__zASTBaseBase.__eq__g   sU    ::T%[[((!!	=EN22 	 	 	55	s   7 
AAintc                h    t          t          | j                                                            S N)hashsortedr1   itemsr4   s    r   __hash__zASTBaseBase.__hash__o   s&    F4=..0011222r!   r   c                     t          |           S r8   r   r<   s    r   clonezASTBaseBase.cloner   s    ~~r!   	transformr   r   c                    t           r8   NotImplementedErrorr4   r@   s     r   
_stringifyzASTBaseBase._stringifyu       !!r!   c                6    |                      t                    S r8   )rE   r   r<   s    r   __str__zASTBaseBase.__str__x   s    s###r!   c                .    |                      d           S )Nc                *    |                                  S r8   )get_display_string)asts    r   <lambda>z0ASTBaseBase.get_display_string.<locals>.<lambda>|   s    3+A+A+C+C r!   )rE   r<   s    r   rK   zASTBaseBase.get_display_string{   s    CCDDDr!   c                    |                      t                    x}rd| j        j         d| dS d| j        j         dS )N<z: >)rE   repr	__class__r%   )r4   repr_strings     r   __repr__zASTBaseBase.__repr__~   sP    //$///; 	A@t~.@@+@@@@-4>*----r!   Nr+   r,   r   r-   r   r6   )r   r   r@   r   r   r   r   r   )
r%   r&   r'   r5   r=   r?   rE   rH   rK   rT   r(   r!   r   r*   r*   f   s           3 3 3 3   " " " "$ $ $ $E E E E. . . . . .r!   r*   c                      e Zd ZddZdS )ASTAttributesignoder   r   r   c                :    t          t          |                     r8   )rC   rQ   r4   r[   s     r   describe_signaturezASTAttribute.describe_signature   s    !$t**---r!   Nr[   r   r   r   )r%   r&   r'   r^   r(   r!   r   rZ   rZ      s(        . . . . . .r!   rZ   c                  6    e Zd ZddZdd	ZddZddZddZdS )ASTCPPAttributeargr   r   r   c                    || _         d S r8   rb   )r4   rb   s     r   __init__zASTCPPAttribute.__init__   s    r!   r+   r,   r-   c                Z    t          |t                    st          S | j        |j        k    S r8   )
isinstancera   r0   rb   r3   s     r   r5   zASTCPPAttribute.__eq__   s)    %11 	"!!x59$$r!   r6   c                *    t          | j                  S r8   )r9   rb   r<   s    r   r=   zASTCPPAttribute.__hash__   s    DH~~r!   r@   r   c                    d| j          dS Nz[[z]]rd   rD   s     r   rE   zASTCPPAttribute._stringify   s     DH    r!   r[   r   c                    |                     t          j        dd                     |                     t          j        | j                             |                     t          j        dd                     d S rj   )appendr   desc_sig_punctuationr   Textrb   r]   s     r   r^   z"ASTCPPAttribute.describe_signature   sd    x4T4@@AAAuz$(++,,,x4T4@@AAAAAr!   N)rb   r   r   r   rU   rV   rW   r_   r%   r&   r'   re   r5   r=   rE   r^   r(   r!   r   ra   ra      s~           % % % %
   ! ! ! !B B B B B Br!   ra   c                  .    e Zd ZddZddZddZddZdS )ASTGnuAttributenamer   argsASTBaseParenExprList | Noner   r   c                "    || _         || _        d S r8   )rr   rs   )r4   rr   rs   s      r   re   zASTGnuAttribute.__init__   s    				r!   r+   r,   r-   c                z    t          |t                    st          S | j        |j        k    o| j        |j        k    S r8   )rg   rq   r0   rr   rs   r3   s     r   r5   zASTGnuAttribute.__eq__   s7    %11 	"!!yEJ&B49
+BBr!   r6   c                8    t          | j        | j        f          S r8   )r9   rr   rs   r<   s    r   r=   zASTGnuAttribute.__hash__   s    TY	*+++r!   r@   r   c                N    | j         r| j         || j                   z   S | j        S r8   )rs   rr   rD   s     r   rE   zASTGnuAttribute._stringify   s-    9 	49yy3333yr!   N)rr   r   rs   rt   r   r   rU   rV   rW   )r%   r&   r'   re   r5   r=   rE   r(   r!   r   rq   rq      sh           C C C C
, , , ,     r!   rq   c                  6    e Zd ZddZdd	ZddZddZddZdS )ASTGnuAttributeListattrslist[ASTGnuAttribute]r   r   c                    || _         d S r8   r{   r4   r{   s     r   re   zASTGnuAttributeList.__init__       


r!   r+   r,   r-   c                Z    t          |t                    st          S | j        |j        k    S r8   )rg   rz   r0   r{   r3   s     r   r5   zASTGnuAttributeList.__eq__   s*    %!455 	"!!zU[((r!   r6   c                *    t          | j                  S r8   r9   r{   r<   s    r   r=   zASTGnuAttributeList.__hash__       DJr!   r@   r   r   c                ^    d                     t          || j                            }d| dS )Nz, z__attribute__((z))joinmapr{   )r4   r@   r{   s      r   rE   zASTGnuAttributeList._stringify   s0    		#i4455*****r!   r[   r   c                n    |                     t          j        t          |                                d S r8   rl   r   rn   r   r]   s     r   r^   z&ASTGnuAttributeList.describe_signature   *    uz#d)),,-----r!   N)r{   r|   r   r   rU   rV   rW   r_   ro   r(   r!   r   rz   rz      sx           ) ) ) )
       + + + +. . . . . .r!   rz   c                  :    e Zd ZdZddZdd
ZddZddZddZdS )ASTIdAttributez*For simple attributes defined by the user.idr   r   r   c                    || _         d S r8   r   )r4   r   s     r   re   zASTIdAttribute.__init__   s    r!   r+   r,   r-   c                Z    t          |t                    st          S | j        |j        k    S r8   )rg   r   r0   r   r3   s     r   r5   zASTIdAttribute.__eq__   s)    %00 	"!!w%(""r!   r6   c                *    t          | j                  S r8   )r9   r   r<   s    r   r=   zASTIdAttribute.__hash__   s    DG}}r!   r@   r   c                    | j         S r8   r   rD   s     r   rE   zASTIdAttribute._stringify   s	    wr!   r[   r   c                ^    |                     t          j        | j                             d S r8   )rl   r   rn   r   r]   s     r   r^   z!ASTIdAttribute.describe_signature   s&    uz$'**+++++r!   N)r   r   r   r   rU   rV   rW   r_   	r%   r&   r'   __doc__re   r5   r=   rE   r^   r(   r!   r   r   r      s~        44   # # # #
      , , , , , ,r!   r   c                  :    e Zd ZdZddZddZddZddZddZdS )ASTParenAttributez)For paren attributes defined by the user.r   r   rb   r   r   c                "    || _         || _        d S r8   r   rb   )r4   r   rb   s      r   re   zASTParenAttribute.__init__   s    r!   r+   r,   r-   c                z    t          |t                    st          S | j        |j        k    o| j        |j        k    S r8   )rg   r   r0   r   rb   r3   s     r   r5   zASTParenAttribute.__eq__   s8    %!233 	"!!w%("<tx59'<<r!   r6   c                8    t          | j        | j        f          S r8   )r9   r   rb   r<   s    r   r=   zASTParenAttribute.__hash__   s    TWdh'(((r!   r@   r   c                &    | j          d| j         dS )N()r   rD   s     r   rE   zASTParenAttribute._stringify   s    '''DH''''r!   r[   r   c                n    |                     t          j        t          |                                d S r8   r   r]   s     r   r^   z$ASTParenAttribute.describe_signature   r   r!   N)r   r   rb   r   r   r   rU   rV   rW   r_   r   r(   r!   r   r   r      s~        33   = = = =
) ) ) )( ( ( (. . . . . .r!   r   c                  F    e Zd ZddZdd	ZddZddZddZddZddZ	dS )ASTAttributeListr{   list[ASTAttribute]r   r   c                    || _         d S r8   r~   r   s     r   re   zASTAttributeList.__init__   r   r!   r+   r,   r-   c                Z    t          |t                    st          S | j        |j        k    S r8   )rg   r   r0   r{   r3   s     r   r5   zASTAttributeList.__eq__   s*    %!122 	"!!zU[((r!   r6   c                *    t          | j                  S r8   r   r<   s    r   r=   zASTAttributeList.__hash__   r   r!   c                *    t          | j                  S r8   )lenr{   r<   s    r   __len__zASTAttributeList.__len__  s    4:r!   c                :    t          | j        |j        z             S r8   )r   r{   r3   s     r   __add__zASTAttributeList.__add__  s    
U[ 8999r!   r@   r   r   c                R    d                     t          || j                            S )N r   rD   s     r   rE   zASTAttributeList._stringify  s     xxItz22333r!   r[   r   c                H   t          | j                  dk    rd S | j        d                             |           t          | j                  dk    rd S | j        dd          D ]=}|                    t	          j                               |                    |           >d S )Nr      )r   r{   r^   rl   r   desc_sig_space)r4   r[   attrs      r   r^   z#ASTAttributeList.describe_signature
  s    tz??aF
1((111tz??aFJqrrN 	- 	-DNN8244555##G,,,,	- 	-r!   N)r{   r   r   r   rU   rV   )r+   r   r   r   rW   r_   )
r%   r&   r'   re   r5   r=   r   r   rE   r^   r(   r!   r   r   r      s           ) ) ) )
          : : : :4 4 4 4- - - - - -r!   r   c                      e Zd ZdS )ASTBaseParenExprListNr$   r(   r!   r   r   r             Dr!   r   c                      e Zd ZdS )$UnsupportedMultiCharacterCharLiteralNr$   r(   r!   r   r   r     r   r!   r   c                      e Zd ZdS )DefinitionErrorNr$   r(   r!   r   r   r   #  r   r!   r   c                  ,   e Zd Zd5d	Zd6dZed7d            Zd8dZd9dZd8dZ	d:dZ
d;dZd<dZd=dZd<dZd;dZed=d             Zed7d!            Zed7d"            Zd7d#Zd$d%d>d'Zed?d)            Zed?d*            Zd@d-ZdAd/ZdBd1ZdCd3Zd4S )D
BaseParser
definitionr   location"nodes.Node | tuple[str, int] | strconfigr   r   r   c                   |                                 | _        || _        || _        d| _        t          | j                  | _        d | _        d| _        g | _	        d| _
        d S )Nr   )r   NT)stripr   r   r   posr   end
last_match_previous_stateotherErrorsallowFallbackExpressionParsing)r4   r   r   r   s       r   re   zBaseParser.__init__(  sd     %**,, t''04AJ24 /3+++r!   errors	list[Any]headerr   c                   t          |          dk    rit          |          dk    r.t          |dz   t          |d         d                   z             S t          t          |d         d                             S |dg}|D ]}t          |d                   dk    rwd}|                    |d         df           t          |d                                       d          D ].}t          |          dk    r|                    ||df           /|                    t          |d                              t          d                    |                    S )Nr   r   
z  z:
 )r   r   r   extendsplitrl   r   )r4   r   r   resulteindentlines          r   _make_multi_errorzBaseParser._make_multi_error<  sB   v;;!6{{Q&v}s6!9Q<7H7H'HIII&s6!9Q<'8'8999$ 		) 		)A1Q4yy1}}qtUm,,,!IIOOD11 8 8D4yyA~~ MM64"677778
 c!A$ii((((rwwv///r!   c                    t           r8   rB   r<   s    r   languagezBaseParser.languageO      !!r!   msgc                n    d| j         z  dz   }t                              | d| j         d|            d S )N-^r   )r   loggerdebugr   )r4   r   	indicators      r   statuszBaseParser.statusS  sB    $(NS(	==t==)==>>>>>r!   r   c           
     .   g }d| j         z  dz   }d| j         d| d| j          d| j         d| 
}t          |          }|                    |df           |                    d	 | j        D                        g | _        |                     |d
          )Nr   r   zInvalid z declaration: z [error at z]
  z
  z
Main errorc              3     K   | ]}|d fV  	dS )zPotential other errorNr(   ).0errs     r   	<genexpr>z"BaseParser.fail.<locals>.<genexpr>b  s(      QQs34QQQQQQr!   r   )r   r   r   r   rl   r   r   r   )r4   r   r   r   exc_mains        r   failzBaseParser.failX  s    $(NS(	t}  C  DH     	
 #3''x.///QQ@PQQQQQQ$$VR000r!   c                H    t                               || j                   d S )N)r   )r   warningr   )r4   r   s     r   warnzBaseParser.warnf  s     sT]33333r!   regexre.Pattern[str]r-   c                    |                     | j        | j                  }|5| j        | j        f| _        |                                | _        || _        dS dS NTF)matchr   r   r   r   r   )r4   r   r   s      r   r   zBaseParser.matchi  sP    DOTX66$(Hdo#>D yy{{DH#DO4ur!   stringc                    t          |          }| j        | j        | j        |z            |k    r| xj        |z  c_        dS dS r   )r   r   r   )r4   r   strlens      r   skip_stringzBaseParser.skip_stringr  sG    V?48dh&778FBBHHHH4ur!   wordc                z    |                      t          j        dt          j        |          z                      S )Nz\b%s\b)r   recompileescaper4   r   s     r   	skip_wordzBaseParser.skip_wordy  s+    zz"*Y4%@AABBBr!   c                6    |                      t                    S r8   )r   _whitespace_rer<   s    r   skip_wszBaseParser.skip_ws|  s    zz.)))r!   c                \    |                      |          r|                                  dS dS r   )r   r   r   s     r   skip_word_and_wszBaseParser.skip_word_and_ws  s-    >>$ 	LLNNN4ur!   c                \    |                      |          r|                                  dS dS r   )r   r   )r4   r   s     r   skip_string_and_wszBaseParser.skip_string_and_ws  s/    F## 	LLNNN4ur!   c                "    | j         | j        k    S r8   )r   r   r<   s    r   eofzBaseParser.eof  s    x48##r!   c                J    	 | j         | j                 S # t          $ r Y dS w xY w)NEOF)r   r   
IndexErrorr<   s    r   current_charzBaseParser.current_char  s8    	?48,, 	 	 	55	s    
""c                F    | j         | j                                         S dS )Nr   )r   groupr<   s    r   matched_textzBaseParser.matched_text  s#    ?&?((***rr!   c                F    | j         | j        d          }| j        | _        |S r8   )r   r   r   )r4   rvs     r   	read_restzBaseParser.read_rest  s"    _TXZZ(8	r!   F)allowSemicolonr  c                   |                                   |r:| j        s/| j        | j        d          dk    r|                     d           d S d S d S | j        s|                     d           d S d S )N;z Expected end of definition or ;.zExpected end of definition.)r   r  r   r   r   )r4   r  s     r   
assert_endzBaseParser.assert_end  s     	98 >

 ;s B B		<=====> > B B 8 9		7888889 9r!   Sequence[str]c                    t           r8   rB   r<   s    r   id_attributeszBaseParser.id_attributes  r   r!   c                    t           r8   rB   r<   s    r   paren_attributeszBaseParser.paren_attributes  r   r!   r   	list[str]c                   dddd}| j         }g }| j        st          |          dk    r
| j        |v rn| j        |v r!|                    || j                            n_t          |          dk    r&| j        |d         k    r|                                 n&| j        dv r|                     d| j        z             | xj         d	z  c_         | j        | j        r|                     d
| d           | j        || j                  S )Nr   ]})r   [{r   z)]}z&Unexpected '%s' in balanced-token-seq.r   z5Could not find end of balanced-token-seq starting at .)r   r  r   r  rl   popr   r   )r4   r   brackets	start_possymbolss        r   _parse_balanced_token_seqz$BaseParser._parse_balanced_token_seq  s.   3S11H	( 		7||q  T%6#%=%= H,,x(9:;;;;W!!d&772;&F&F"e++		BTEVVWWWHHMHH ( 		 8 	IIT	TTT   y48344r!   ASTAttribute | Nonec                   |                                   | j        }|                     d          r|                     d          s|| _        nz|                     dg          }|                     d          s|                     d           |                     d          s|                     d           t          |          S |                     d          r*|                     d          s|                     d           |                     d          s|                     d	           g }	 |                     t                    r>| j
        }|                                 }|                    t          ||                     |                     d          ro|                     d          rn|                     d           |                     d          s|                     d           t          |          S | j        D ](}|                     |          rt!          |          c S )| j        D ]}|                     |          s|                     d          s|                     d           |                     dg          }|                     d          s|                     d           t%          ||          c S d S )Nr  r  )r   z!Expected ']' in end of attribute.z-Expected ']' in end of attribute after [[...]__attribute__r   z#Expected '(' after '__attribute__'.z$Expected '(' after '__attribute__('.r   ,r   z2Expected identifier, ')', or ',' in __attribute__.z(Expected ')' after '__attribute__((...)'z0Expected '(' after user-defined paren-attribute.z1Expected ')' to end user-defined paren-attribute.)r   r   r   r   r!  r   ra   r   r   identifier_rer  _parse_paren_expression_listrl   rq   rz   r  r   r  r   )r4   r  rb   r{   rr   exprsr   s          r   _parse_attributezBaseParser._parse_attribute  s   H	""3'' 
	,##C(( 	,$ 44#4??..s33 CIIABBB..s33 OIIMNNN&s+++   11 	.**3// A		?@@@**3// B		@AAAE	P::m,, ?,D ==??ELLu!=!=>>>**3// **3// 		NOOO	P **3// F		DEEE&u--- $ 	* 	*B$$R(( *%b)))))* ' 	. 	.B**2.. ##C(( N		LMMM00cU0;;C##C(( O		MNNN$R-----tr!   r   c                    g }	 |                                  }|n|                    |           -t          |          S r8   )r)  rl   r   )r4   resr   s      r   _parse_attribute_listz BaseParser._parse_attribute_list   sL    	((**D|JJt		
  $$$r!   rt   c                    t           r8   rB   r<   s    r   r'  z'BaseParser._parse_paren_expression_list	  rF   r!   N)r   r   r   r   r   r   r   r   )r   r   r   r   r   r   rX   )r   r   r   r   )r   r   r   r   )r   r   r   r-   )r   r   r   r-   )r   r   r   r-   )r   r-   )r  r-   r   r   )r   r  )r   r  r   r   )r   r"  )r   r   )r   rt   )r%   r&   r'   re   r   propertyr   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r  r!  r)  r,  r'  r(   r!   r   r   r   '  s<       3 3 3 3(0 0 0 0& " " " X"? ? ? ?
1 1 1 14 4 4 4      C C C C* * * *       $ $ $ X$    X    X
   
 49 9 9 9 9 9 9 " " " X" " " " X"5 5 5 5*5 5 5 5n% % % %" " " " " "r!   r   )r   r   r   r   ):r   
__future__r   r   copyr   typingr   docutilsr   sphinxr   sphinx.utilr	   collections.abcr
   r   r   r   r   docutils.nodesr   sphinx.configr   r   r   __annotations__	getLoggerr%   r   r   r   anon_identifier_reVERBOSEr&  integer_literal_reoctal_literal_rehex_literal_rebinary_literal_reintegers_literal_suffix_refloat_literal_refloat_literal_suffix_rechar_literal_rer    r   r#   r*   rZ   ra   rq   rz   r   r   r   r   r   r   r   r(   r!   r   <module>rD     s   8 8 8 " " " " " " 				                                     922222222//////////******$$$$$$$,cUCZ$88888		8	$	$F##RZ ABB 
 *
 
 
  RZ 9:: 2:344 ABBBJ677 'RZ	 *    2: *     %"*[11 "* *  $D D D D
	 	 	 	 	9 	 	 	
. . . . . . . .F. . . . .; . . .
B B B B Bl B B B*    k   &. . . . ., . . .(, , , , ,\ , , ,*. . . . . . . .,- - - - -{ - - -F	 	 	 	 	; 	 	 		 	 	 	 	9 	 	 		 	 	 	 	i 	 	 	c" c" c" c" c" c" c" c" c" c"r!   