
    7 fZ<                       d Z ddlmZ ddlZddlmZ ddlmZmZm	Z	 ddl
mZ ddlmZ ddlmZ erdd	lmZ dd
lmZ  ej        e          Ze	egef         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%d6dZ& G d de'          Z( G d d          Z) G d  d!e)          Z* G d" d#e*          Z+ G d$ d%e)          Z, G d& d'e*          Z- G d( d)e*          Z. G d* d+e*          Z/ G d, d-e)          Z0 G d. d/e)          Z1 G d0 d1e'          Z2 G d2 d3e'          Z3 G d4 d5          Z4dS )7z2Utility functions common to the C and C++ domains.    )annotationsNdeepcopy)TYPE_CHECKINGAnyCallable)nodes)addnodes)logging)TextElement)Configz\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)
lastIsName
noneIsNamemarkTypemarkNameparamudlz!Description mode '%s' is invalid.)	Exception)r   s    I/var/www/equiseq/venv/lib/python3.11/site-packages/sphinx/util/cfamily.pyverify_description_moder   N   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   S   s        Dr   r   c                  B    e Zd ZddZdZddZddZddZddZddZ	dS )ASTBaseBaseotherr   r   boolc                    t          |           t          |          urdS 	 | j                                        D ]\  }}|t          ||          k    r dS n# t          $ r Y dS w xY wdS )NFT)type__dict__itemsgetattrAttributeError)selfr'   keyvalues       r   __eq__zASTBaseBase.__eq__Y   s    ::T%[[((5	"m1133 ! !
UGE3//// 55 0!  	 	 	55	ts   3A A 
A'&A'Nc                     t          |           S Nr   r/   s    r   clonezASTBaseBase.cloneg   s    ~~r   	transformStringifyTransformr   c                :    t          t          |                     r4   NotImplementedErrorreprr/   r7   s     r   
_stringifyzASTBaseBase._stringifyj       !$t**---r   c                .    |                      d           S )Nc                     t          |           S r4   )r   asts    r   <lambda>z%ASTBaseBase.__str__.<locals>.<lambda>n   s    3s88 r   r>   r5   s    r   __str__zASTBaseBase.__str__m   s    33444r   c                .    |                      d           S )Nc                *    |                                  S r4   )get_display_stringrB   s    r   rD   z0ASTBaseBase.get_display_string.<locals>.<lambda>q   s    3+A+A+C+C r   rE   r5   s    r   rI   zASTBaseBase.get_display_stringp   s    CCDDDr   c                     d| j         j        z  S )Nz<%s>)	__class__r!   r5   s    r   __repr__zASTBaseBase.__repr__s   s    ///r   )r'   r   r   r(   )r   r   r7   r8   r   r   r   r   )
r!   r"   r#   r2   __hash__r6   r>   rF   rI   rL   r$   r   r   r&   r&   X   s        	 	 	 	 H   . . . .5 5 5 5E E E E0 0 0 0 0 0r   r&   c                      e Zd ZddZdS )ASTAttributesignoder   r   r   c                :    t          t          |                     r4   r:   r/   rR   s     r   describe_signaturezASTAttribute.describe_signature|   r?   r   NrR   r   r   r   )r!   r"   r#   rU   r$   r   r   rQ   rQ   {   s(        . . . . . .r   rQ   c                  &    e Zd ZddZddZddZdS )ASTCPPAttributeargr   r   r   c                    || _         d S r4   rY   )r/   rY   s     r   __init__zASTCPPAttribute.__init__   s    r   r7   r8   c                    d| j         z   dz   S Nz[[z]]r[   r=   s     r   r>   zASTCPPAttribute._stringify   s    dh%%r   rR   r   c                    |                     t          j        dd                     |                     t          j        | j                             |                     t          j        dd                     d S r^   )appendr
   desc_sig_punctuationr	   TextrY   rT   s     r   rU   z"ASTCPPAttribute.describe_signature   sd    x4T4@@AAAuz$(++,,,x4T4@@AAAAAr   N)rY   r   r   r   rM   rV   r!   r"   r#   r\   r>   rU   r$   r   r   rX   rX      sV           & & & &B B B B B Br   rX   c                      e Zd ZddZdd
ZdS )ASTGnuAttributenamer   argsASTBaseParenExprList | Noner   r   c                "    || _         || _        d S r4   )rf   rg   )r/   rf   rg   s      r   r\   zASTGnuAttribute.__init__   s    				r   r7   r8   c                    | j         g}| j        r#|                     || j                             d                    |          S N )rf   rg   r`   join)r/   r7   ress      r   r>   zASTGnuAttribute._stringify   sC    yk9 	-JJyy++,,,wws||r   N)rf   r   rg   rh   r   r   rM   )r!   r"   r#   r\   r>   r$   r   r   re   re      s<                r   re   c                  &    e Zd ZddZdd	ZddZdS )ASTGnuAttributeListattrslist[ASTGnuAttribute]r   r   c                    || _         d S r4   rq   r/   rq   s     r   r\   zASTGnuAttributeList.__init__       


r   r7   r8   r   c                    dg}d}| j         D ]9}|s|                    d           d}|                     ||                     :|                    d           d                    |          S )Nz__attribute__((Tz, Fz))rl   )rq   r`   rm   )r/   r7   rn   firstattrs        r   r>   zASTGnuAttributeList._stringify   s~     !J 	( 	(D !

4   EJJyy''''

4wws||r   rR   r   c                r    t          |           }|                    t          j        |                     d S r4   r   r`   r	   rb   r/   rR   txts      r   rU   z&ASTGnuAttributeList.describe_signature   -    $iiuz#'''''r   N)rq   rr   r   r   rM   rV   rc   r$   r   r   rp   rp      sP           	 	 	 	( ( ( ( ( (r   rp   c                  *    e Zd Z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 r4   r   )r/   r   s     r   r\   zASTIdAttribute.__init__   s    r   r7   r8   c                    | j         S r4   r   r=   s     r   r>   zASTIdAttribute._stringify   s	    wr   rR   r   c                ^    |                     t          j        | j                             d S r4   )r`   r	   rb   r   rT   s     r   rU   z!ASTIdAttribute.describe_signature   s&    uz$'**+++++r   N)r   r   r   r   rM   rV   r!   r"   r#   __doc__r\   r>   rU   r$   r   r   r   r      sV        44      , , , , , ,r   r   c                  *    e Zd ZdZddZdd
ZddZdS )ASTParenAttributez)For paren attributes defined by the user.r   r   rY   r   r   c                "    || _         || _        d S r4   r   rY   )r/   r   rY   s      r   r\   zASTParenAttribute.__init__   s    r   r7   r8   c                ,    | j         dz   | j        z   dz   S )N()r   r=   s     r   r>   zASTParenAttribute._stringify   s    w}tx'#--r   rR   r   c                r    t          |           }|                    t          j        |                     d S r4   r{   r|   s      r   rU   z$ASTParenAttribute.describe_signature   r~   r   N)r   r   rY   r   r   r   rM   rV   r   r$   r   r   r   r      sV        33   . . . .( ( ( ( ( (r   r   c                  6    e Zd ZddZddZdd	ZddZddZdS )ASTAttributeListrq   list[ASTAttribute]r   r   c                    || _         d S r4   rt   ru   s     r   r\   zASTAttributeList.__init__   rv   r   intc                *    t          | j                  S r4   )lenrq   r5   s    r   __len__zASTAttributeList.__len__   s    4:r   r'   c                :    t          | j        |j        z             S r4   )r   rq   )r/   r'   s     r   __add__zASTAttributeList.__add__   s    
U[ 8999r   r7   r8   r   c                P    d                     fd| j        D                       S )N c              3  .   K   | ]} |          V  d S r4   r$   ).0ry   r7   s     r   	<genexpr>z.ASTAttributeList._stringify.<locals>.<genexpr>   s+      ??D		$??????r   )rm   rq   r=   s    `r   r>   zASTAttributeList._stringify   s,    xx????DJ??????r   rR   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   rq   rU   r`   r
   desc_sig_space)r/   rR   ry   s      r   rU   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)rq   r   r   r   )r   r   )r'   r   r   r   rM   rV   )r!   r"   r#   r\   r   r   r>   rU   r$   r   r   r   r      s|              : : : :@ @ @ @- - - - - -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d3d	Zd4dZed5d            Zd6dZd6dZd6dZ	d7dZ
d8dZd9dZd:dZd9dZd8dZed:d            Zed5d             Zed5d!            Zd5d"Zd#d$d;d&Zed'             Zed(             Zd<d+Zd=d-Zd>d/Zd?d1Zd2S )@
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)r/   r   r   r   s       r   r\   zBaseParser.__init__   sd     %**,, t''04AJ24 /3+++r   errors	list[Any]headerr   c                4   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    rd}|                    |d                    |                    d           t          |d                                       d          D ]U}t          |          dk    r|                    |           |                    |           |                    d           V|                    t          |d                              t          d                    |                    S )Nr   r   
z  z:
rl   )r   r   r   r`   splitrm   )r/   r   r   resulteindentlines          r   _make_multi_errorzBaseParser._make_multi_error  sm   v;;!6{{Q&v}s6!9Q<7H7H'HIII&s6!9Q<'8'8999$ 	) 	)A1Q4yy1}}ad###e$$$!IIOOD11 ( (D4yyA~~ MM&)))MM$'''MM$''''( c!A$ii((((rwwv///r   c                    t           r4   r;   r5   s    r   languagezBaseParser.language      !!r   msgc                n    d| j         z  dz   }t                              | d| j         d|            d S )N-^r   )r   loggerdebugr   )r/   r   	indicators      r   statuszBaseParser.status  sB    $(NS(	==t==)==>>>>>r   c                   g }d| j         z  dz   }t          d| j        || j         | j        |fz            }|                    |df           | j        D ]}|                    |df           g | _        |                     |d          )Nr   r   z2Invalid %s declaration: %s [error at %d]
  %s
  %sz
Main errorzPotential other errorrl   )r   r   r   r   r`   r   r   )r/   r   r   r   exMainerrs         r   failzBaseParser.fail!  s    $(NS(	 B]C4?IFGH H 	v|,---# 	: 	:CMM3 789999$$VR000r   c                H    t                               || j                   d S )N)r   )r   warningr   )r/   r   s     r   warnzBaseParser.warn-  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   )r/   r   r   s      r   r   zBaseParser.match0  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   )r/   r   strlens      r   skip_stringzBaseParser.skip_string9  sG    V?48DHv$556&@@HHHH4ur   wordc                z    |                      t          j        dt          j        |          z                      S )Nz\b%s\b)r   recompileescaper/   r   s     r   	skip_wordzBaseParser.skip_word@  s+    zz"*Y4%@AABBBr   c                6    |                      t                    S r4   )r   _whitespace_rer5   s    r   skip_wszBaseParser.skip_wsC  s    zz.)))r   c                \    |                      |          r|                                  dS dS r   )r   r   r   s     r   skip_word_and_wszBaseParser.skip_word_and_wsF  s-    >>$ 	LLNNN4ur   c                \    |                      |          r|                                  dS dS r   )r   r   )r/   r   s     r   skip_string_and_wszBaseParser.skip_string_and_wsL  s/    F## 	LLNNN4ur   c                "    | j         | j        k    S r4   )r   r   r5   s    r   eofzBaseParser.eofR  s    x48##r   c                J    	 | j         | j                 S # t          $ r Y dS w xY w)NEOF)r   r   
IndexErrorr5   s    r   current_charzBaseParser.current_charV  s8    	?48,, 	 	 	55	s    
""c                F    | j         | j                                         S dS rk   )r   groupr5   s    r   matched_textzBaseParser.matched_text]  s#    ?&?((***rr   c                F    | j         | j        d          }| j        | _        |S r4   )r   r   r   )r/   rvs     r   	read_restzBaseParser.read_restc  s"    _TXYY'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   )r/   r   s     r   
assert_endzBaseParser.assert_endh  s     	98 >		 :c A A		<=====> > A A 8 9		7888889 9r   c                    t           r4   r   r5   s    r   id_attributeszBaseParser.id_attributess  r   r   c                    t           r4   r   r5   s    r   paren_attributeszBaseParser.paren_attributesw  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
|z             | j        || j                  S )Nr   ]})r   [{r   z)]}z&Unexpected '%s' in balanced-token-seq.r   z8Could not find end of balanced-token-seq starting at %d.)r   r   r   r   r`   popr   r   )r/   r   bracketsstartPossymbolss        r   _parse_balanced_token_seqz$BaseParser._parse_balanced_token_seq{  s)   3S118( 		7||q  T%6#%=%= H,,x(9:;;;;W!!d&772;&F&F"e++		BTEVVWWWHHMHH ( 		 8 	"IIP ! " " "x011r   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   rX   r   r   identifier_rer   _parse_paren_expression_listr`   re   rp   r   r   r   r   )r/   r	  rY   rq   rf   exprsr   s          r   _parse_attributezBaseParser._parse_attribute  s   8""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 r4   )r  r`   r   )r/   rn   ry   s      r   _parse_attribute_listz BaseParser._parse_attribute_list  sL    	((**D|JJt		
  $$$r   rh   c                    t           r4   r   r5   s    r   r  z'BaseParser._parse_paren_expression_list  s    !!r   N)r   r   r   r   r   r   r   r   )r   r   r   r   r   r   rN   )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   rh   )r!   r"   r#   r\   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      s2       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"2 2 2 2(5 5 5 5n% % % %" " " " " "r   r   )r   r   r   r   )5r   
__future__r   r   copyr   typingr   r   r   docutilsr	   sphinxr
   sphinx.utilr   docutils.nodesr   sphinx.configr   	getLoggerr!   r   r   r8   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&   rQ   rX   re   rp   r   r   r   r   r   r   r   r$   r   r   <module>r+     sI   8 8 " " " " " " 				       / / / / / / / / / /                   %******$$$$$$		8	$	$seSj)  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 	 	 	
0 0 0 0 0 0 0 0F. . . . .; . . .

B 
B 
B 
B 
Bl 
B 
B 
B	 	 	 	 	k 	 	 	( ( ( ( (, ( ( ((
, 
, 
, 
, 
,\ 
, 
, 
,( ( ( ( ( ( ( (- - - - -{ - - -4	 	 	 	 	; 	 	 		 	 	 	 	9 	 	 		 	 	 	 	i 	 	 	_" _" _" _" _" _" _" _" _" _"r   