o
    "“iÆ& ã                   @   sd   d dl mZ d dlmZ d dlmZ d dlmZmZm	Z	m
Z
 d dlmZmZ e
G dd„ deƒƒZdS )	é   )Úyacc)Úc_ast)ÚCLexer)Ú	PLYParserÚ
ParseErrorÚparameterizedÚtemplate)Úfix_switch_casesÚfix_atomic_specifiersc                   @   sÈ  e Zd Zdedddddfdd„Z�dgdd	„Zd
d„ Zdd„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Z�dhd"d#„Z�dhd$d%„Zd&d'„ Zd(d)„ Zd*Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Zd9d:„ Zd;d<„ Zd=d>„ Z d?d@„ Z!dAdB„ Z"dCdD„ Z#dEdF„ Z$dGdH„ Z%dIdJ„ Z&dKdL„ Z'dMdN„ Z(dOdP„ Z)dQdR„ Z*dSdT„ Z+dUdV„ Z,dWdX„ Z-dYdZ„ Z.d[d\„ Z/d]d^„ Z0d_d`„ Z1dadb„ Z2dcdd„ Z3dedf„ Z4dgdh„ Z5didj„ Z6dkdl„ Z7dmdn„ Z8dodp„ Z9dqdr„ Z:dsdt„ Z;dudv„ Z<dwdx„ Z=dydz„ Z>d{d|„ Z?d}d~„ Z@dd€„ ZAd�d‚„ ZBdƒd„„ ZCd…d†„ ZDd‡dˆ„ ZEd‰dŠ„ ZFd‹dŒ„ ZGd�dŽ„ ZHd�d�„ ZId‘d’„ ZJd“d”„ ZKd•d–„ ZLd—d˜„ ZMd™dš„ ZNd›dœ„ ZOd�dž„ ZPdŸd „ ZQd¡d¢„ ZRd£d¤„ ZSd¥d¦„ ZTd§d¨„ ZUd©dª„ ZVd«d¬„ ZWeXd­d®d¯ƒd°d±„ ƒZYeXd­d®d¯ƒd²d³„ ƒZZeXd­d®d¯ƒd´dµ„ ƒZ[eXd­d®ƒd¶d·„ ƒZ\eXd­d®d¯ƒd¸d¹„ ƒZ]eXd­d®d¯ƒdºd»„ ƒZ^eXd­d®d¯ƒd¼d½„ ƒZ_eXd­d®d¯ƒd¾d¿„ ƒZ`dÀdÁ„ ZadÂdÃ„ ZbdÄdÅ„ ZcdÆdÇ„ ZddÈdÉ„ ZedÊdË„ ZfdÌdÍ„ ZgdÎdÏ„ ZhdÐdÑ„ ZidÒdÓ„ ZjdÔdÕ„ ZkdÖd×„ ZldØdÙ„ ZmdÚdÛ„ ZndÜdÝ„ ZodÞdß„ Zpdàdá„ Zqdâdã„ Zrdädå„ Zsdædç„ Ztdèdé„ Zudêdë„ Zvdìdí„ Zwdîdï„ Zxdðdñ„ Zydòdó„ Zzdôdõ„ Z{död÷„ Z|dødù„ Z}dúdû„ Z~düdý„ Zdþdÿ„ Z€�d �d„ Z��d�d„ Z‚�d�d„ Zƒ�d�d„ Z„�d�d	„ Z…�d
�d„ Z†�d�d„ Z‡�d�d„ Zˆ�d�d„ Z‰�d�d„ ZŠ�d�d„ Z‹�d�d„ ZŒ�d�d„ Z��d�d„ ZŽ�d�d„ Z��d�d„ Z��d �d!„ Z‘�d"�d#„ Z’�d$�d%„ Z“�d&�d'„ Z”�d(�d)„ Z•�d*�d+„ Z–�d,�d-„ Z—�d.�d/„ Z˜�d0�d1„ Z™�d2�d3„ Zš�d4�d5„ Z›�d6�d7„ Zœ�d8�d9„ Z��d:�d;„ Zž�d<�d=„ ZŸ�d>�d?„ Z �d@�dA„ Z¡�dB�dC„ Z¢�dD�dE„ Z£�dF�dG„ Z¤�dH�dI„ Z¥�dJ�dK„ Z¦�dL�dM„ Z§�dN�dO„ Z¨�dP�dQ„ Z©�dR�dS„ Zª�dT�dU„ Z«�dV�dW„ Z¬�dX�dY„ Z­�dZ�d[„ Z®�d\�d]„ Z¯�d^�d_„ Z°�d`�da„ Z±�db�dc„ Z²�dd�de„ Z³�dfS (i  ÚCParserTzpycparser.lextabzpycparser.yacctabFÚ c           
      C   s~   || j | j| j| jd�| _| jj|||d� | jj| _g d¢}|D ]}	|  |	¡ q!tj| d||||d�| _	t
ƒ g| _d| _dS )a   Create a new CParser.

            Some arguments for controlling the debug/optimization
            level of the parser are provided. The defaults are
            tuned for release/performance mode.
            The simple rules for using them are:
            *) When tweaking CParser/CLexer, set these to False
            *) When releasing a stable parser, set to True

            lex_optimize:
                Set to False when you're modifying the lexer.
                Otherwise, changes in the lexer won't be used, if
                some lextab.py file exists.
                When releasing with a stable lexer, set to True
                to save the re-generation of the lexer table on
                each run.

            lexer:
                Set this parameter to define the lexer to use if
                you're not using the default CLexer.

            lextab:
                Points to the lex table that's used for optimized
                mode. Only if you're modifying the lexer and want
                some tests to avoid re-generating the table, make
                this point to a local lex table file (that's been
                earlier generated with lex_optimize=True)

            yacc_optimize:
                Set to False when you're modifying the parser.
                Otherwise, changes in the parser won't be used, if
                some parsetab.py file exists.
                When releasing with a stable parser, set to True
                to save the re-generation of the parser table on
                each run.

            yacctab:
                Points to the yacc table that's used for optimized
                mode. Only if you're modifying the parser, make
                this point to a local yacc table file

            yacc_debug:
                Generate a parser.out file that explains how yacc
                built the parsing table from the grammar.

            taboutputdir:
                Set this parameter to control the location of generated
                lextab and yacctab files.
        )Ú
error_funcÚon_lbrace_funcÚon_rbrace_funcÚtype_lookup_func)ÚoptimizeÚlextabÚ	outputdir)Úabstract_declaratorÚassignment_expressionÚdeclaration_listÚdeclaration_specifiers_no_typeÚdesignationÚ
expressionÚidentifier_listÚinit_declarator_listÚid_init_declarator_listÚinitializer_listÚparameter_type_listÚblock_item_listÚtype_qualifier_listÚstruct_declarator_listÚtranslation_unit_or_empty)ÚmoduleÚstartÚdebugr   Ú	tabmoduler   N)Ú_lex_error_funcÚ_lex_on_lbrace_funcÚ_lex_on_rbrace_funcÚ_lex_type_lookup_funcÚclexÚbuildÚtokensÚ_create_opt_ruler   ÚcparserÚdictÚ_scope_stackÚ_last_yielded_token)
ÚselfÚlex_optimizeÚlexerr   Úyacc_optimizeÚyacctabÚ
yacc_debugÚtaboutputdirÚrules_with_optÚrule© r<   úR/var/www/html/premium_crap/venv/lib/python3.10/site-packages/pycparser/c_parser.pyÚ__init__   s2   :üý
ú

zCParser.__init__c                 C   s6   || j _| j  ¡  tƒ g| _d| _| jj|| j |d�S )a    Parses C code and returns an AST.

            text:
                A string containing the C source code

            filename:
                Name of the file being parsed (for meaningful
                error messages)

            debug:
                Debug flag to YACC
        N)Úinputr5   r%   )r+   ÚfilenameÚreset_linenor0   r1   r2   r/   Úparse)r3   Útextr@   r%   r<   r<   r=   rB   ‚   s   

ýzCParser.parsec                 C   s   | j  tƒ ¡ d S ©N)r1   Úappendr0   ©r3   r<   r<   r=   Ú_push_scopeš   s   zCParser._push_scopec                 C   s    t | jƒdks	J ‚| j ¡  d S )Nr   )Úlenr1   ÚpoprF   r<   r<   r=   Ú
_pop_scope�   s   zCParser._pop_scopec                 C   s4   | j d  |d¡s|  d| |¡ d| j d |< dS )zC Add a new typedef name (ie a TYPEID) to the current scope
        éÿÿÿÿTz;Typedef %r previously declared as non-typedef in this scopeN©r1   ÚgetÚ_parse_error©r3   ÚnameÚcoordr<   r<   r=   Ú_add_typedef_name¡   s   ÿþzCParser._add_typedef_namec                 C   s4   | j d  |d¡r|  d| |¡ d| j d |< dS )ze Add a new object, function, or enum member name (ie an ID) to the
            current scope
        rK   Fz;Non-typedef %r previously declared as typedef in this scopeNrL   rO   r<   r<   r=   Ú_add_identifierª   s   ÿþzCParser._add_identifierc                 C   s.   t | jƒD ]}| |¡}|dur|  S qdS )z8 Is *name* a typedef-name in the current scope?
        NF)Úreversedr1   rM   )r3   rP   ÚscopeÚin_scoper<   r<   r=   Ú_is_type_in_scope´   s   
zCParser._is_type_in_scopec                 C   s   |   ||  ||¡¡ d S rD   )rN   Ú_coord)r3   ÚmsgÚlineÚcolumnr<   r<   r=   r'   ¾   s   zCParser._lex_error_funcc                 C   ó   |   ¡  d S rD   )rG   rF   r<   r<   r=   r(   Á   ó   zCParser._lex_on_lbrace_funcc                 C   r\   rD   )rJ   rF   r<   r<   r=   r)   Ä   r]   zCParser._lex_on_rbrace_funcc                 C   s   |   |¡}|S )z§ Looks up types that were previously defined with
            typedef.
            Passed to the lexer for recognizing identifiers that
            are types.
        )rW   )r3   rP   Úis_typer<   r<   r=   r*   Ç   s   
zCParser._lex_type_lookup_funcc                 C   s   | j jS )z§ We need access to yacc's lookahead token in certain cases.
            This is the last token yacc requested from the lexer, so we
            ask the lexer.
        )r+   Ú
last_tokenrF   r<   r<   r=   Ú_get_yacc_lookahead_tokenÐ   s   z!CParser._get_yacc_lookahead_tokenc                 C   sh   |}|}|j r|j }|j st|tjƒr||_ |S |}t|j tjƒs+|j }t|j tjƒr!|j |_ ||_ |S )z  Tacks a type modifier on a declarator, and returns
            the modified declarator.

            Note: the declarator and modifier may be modified
        )ÚtypeÚ
isinstancer   ÚTypeDecl)r3   ÚdeclÚmodifierÚmodifier_headÚmodifier_tailÚ	decl_tailr<   r<   r=   Ú_type_modify_declù   s   ÿÿzCParser._type_modify_declc                 C   sÖ   |}t |tjƒs|j}t |tjƒr|j|_|jdd… |_|D ]}t |tjƒs<t|ƒdkr5|  	d|j
¡ q||_|  S q|sYt |jtjƒsM|  	d|j
¡ tjdg|j
d�|_|S tjdd„ |D ƒ|d	 j
d�|_|S )
z- Fixes a declaration. Modifies decl.
        Nr   z Invalid multiple types specifiedzMissing type in declarationÚint©rQ   c                 S   s   g | ]
}|j D ]}|‘qqS r<   )Únames)Ú.0ÚidrP   r<   r<   r=   Ú
<listcomp>S  s    z/CParser._fix_decl_name_type.<locals>.<listcomp>é    )rb   r   rc   ra   ÚdeclnamerP   ÚqualsÚIdentifierTyperH   rN   rQ   ÚFuncDecl)r3   rd   Útypenamera   Útnr<   r<   r=   Ú_fix_decl_name_type+  s<   ÿÿúÿþ
ýþzCParser._fix_decl_name_typec                 C   s@   |p
t g g g g g d�}|r||  |¡ |S ||  d|¡ |S )a¿   Declaration specifiers are represented by a dictionary
            with the entries:
            * qual: a list of type qualifiers
            * storage: a list of storage type qualifiers
            * type: a list of type specifiers
            * function: a list of function specifiers
            * alignment: a list of alignment specifiers

            This method is given a declaration specifier, and a
            new specifier of a given kind.
            If `append` is True, the new specifier is added to the end of
            the specifiers list, otherwise it's added at the beginning.
            Returns the declaration specifier, with the new
            specifier incorporated.
        )ÚqualÚstoragera   ÚfunctionÚ	alignmentrp   )r0   rE   Úinsert)r3   ÚdeclspecÚnewspecÚkindrE   Úspecr<   r<   r=   Ú_add_declaration_specifierW  s   þz"CParser._add_declaration_specifierc                 C   s\  d|d v }g }|d   d¡durnœ|d d du rtt|d ƒdk s9t|d d	 jƒd
ks9|  |d d	 jd ¡sRd}|d D ]}t|dƒrK|j} nq?|  d|¡ tj|d d	 jd dd|d |d d	 jd�|d d< |d d	= n:t	|d d tj
tjtjtjfƒs®|d d }t	|tjƒsš|j}t	|tjƒr‘|jdu r®|d d	 jd |_|d d	= |D ]{}	|	d dusºJ ‚|rÐtjd|d |d |	d |	d jd�}
n!tjd|d |d |d |d |	d |	  d¡|	  d¡|	d jd�	}
t	|
jtj
tjtjtjfƒ�r|
}n|  |
|d ¡}|�r"|�r|  |j|j¡ n|  |j|j¡ t|ƒ}| |¡ q°|S )zÿ Builds a list of declarations all sharing the given specifiers.
            If typedef_namespace is true, each declared name is added
            to the "typedef namespace", which also includes objects,
            functions, and enum constants.
        Útypedefry   rp   ÚbitsizeNrd   ra   é   rK   r   ú?rQ   zInvalid declarationr{   ©rq   ra   rr   ÚalignrQ   rx   )rP   rr   ry   ra   rQ   rz   Úinit©	rP   rr   r‡   ry   Úfuncspecra   rˆ   rƒ   rQ   )rM   rH   rl   rW   ÚhasattrrQ   rN   r   rc   rb   ÚEnumÚStructÚUnionrs   ra   rq   ÚTypedefÚDeclrw   rR   rP   rS   r
   rE   )r3   r€   ÚdeclsÚtypedef_namespaceÚ
is_typedefÚdeclarationsrQ   ÚtÚdecls_0_tailrd   ÚdeclarationÚ
fixed_declr<   r<   r=   Ú_build_declarationsp  s†   &ÿ
þûÿÿ

û÷þzCParser._build_declarationsc                 C   sL   d|d v r|   d|j¡ | j|t|dd�gdd�d }tj||||jd	�S )
z' Builds a function definition.
        r‚   ry   zInvalid typedefN©rd   rˆ   T©r€   r‘   r’   rp   )rd   Úparam_declsÚbodyrQ   )rN   rQ   r™   r0   r   ÚFuncDef)r3   r€   rd   rœ   r�   r—   r<   r<   r=   Ú_build_function_definitionÉ  s   ýýüz"CParser._build_function_definitionc                 C   s   |dkrt jS t jS )z` Given a token (either STRUCT or UNION), selects the
            appropriate AST class.
        Ústruct)r   r�   rŽ   )r3   Útokenr<   r<   r=   Ú_select_struct_union_classÚ  s   z"CParser._select_struct_union_class)
)ÚleftÚLOR)r£   ÚLAND)r£   ÚOR)r£   ÚXOR)r£   ÚAND)r£   ÚEQÚNE)r£   ÚGTÚGEÚLTÚLE)r£   ÚRSHIFTÚLSHIFT)r£   ÚPLUSÚMINUS)r£   ÚTIMESÚDIVIDEÚMODc                 C   s4   |d du rt  g ¡|d< dS t  |d ¡|d< dS )zh translation_unit_or_empty   : translation_unit
                                        | empty
        r   Nrp   )r   ÚFileAST©r3   Úpr<   r<   r=   Úp_translation_unit_or_emptyü  s   z#CParser.p_translation_unit_or_emptyc                 C   ó   |d |d< dS )z4 translation_unit    : external_declaration
        r   rp   Nr<   r·   r<   r<   r=   Úp_translation_unit_1  ó   zCParser.p_translation_unit_1c                 C   s"   |d   |d ¡ |d |d< dS )zE translation_unit    : translation_unit external_declaration
        r   r„   rp   N)Úextendr·   r<   r<   r=   Úp_translation_unit_2  s   zCParser.p_translation_unit_2c                 C   ó   |d g|d< dS )z7 external_declaration    : function_definition
        r   rp   Nr<   r·   r<   r<   r=   Úp_external_declaration_1  ó   z CParser.p_external_declaration_1c                 C   rº   )z/ external_declaration    : declaration
        r   rp   Nr<   r·   r<   r<   r=   Úp_external_declaration_2  ó   z CParser.p_external_declaration_2c                 C   r¿   )zi external_declaration    : pp_directive
                                    | pppragma_directive
        r   rp   Nr<   r·   r<   r<   r=   Úp_external_declaration_3  s   z CParser.p_external_declaration_3c                 C   s   g |d< dS )z( external_declaration    : SEMI
        rp   Nr<   r·   r<   r<   r=   Úp_external_declaration_4%  ó   z CParser.p_external_declaration_4c                 C   rº   )z1 external_declaration    : static_assert
        r   rp   Nr<   r·   r<   r<   r=   Úp_external_declaration_5*  rÃ   z CParser.p_external_declaration_5c                 C   sX   t |ƒdkrt |d d|  |d¡¡g|d< dS t |d |d |  |d¡¡g|d< dS )zÈ static_assert           : _STATIC_ASSERT LPAREN constant_expression COMMA unified_string_literal RPAREN
                                    | _STATIC_ASSERT LPAREN constant_expression RPAREN
        é   é   Nr   rp   )rH   r   ÚStaticAssertÚ_token_coordr·   r<   r<   r=   Úp_static_assert_declaration/  s   $(z#CParser.p_static_assert_declarationc                 C   s   |   d|  |d¡¡ dS )z  pp_directive  : PPHASH
        zDirectives not supported yetr   N)rN   rË   r·   r<   r<   r=   Úp_pp_directive8  s   
ÿzCParser.p_pp_directivec                 C   st   t |ƒdkrt |d |  |d¡¡|d< dS t |ƒdkr,t |d |  |d¡¡|d< dS t d|  |d¡¡|d< dS )zº pppragma_directive      : PPPRAGMA
                                    | PPPRAGMA PPPRAGMASTR
                                    | _PRAGMA LPAREN unified_string_literal RPAREN
        rÈ   rÉ   r„   rp   r   r   N)rH   r   ÚPragmarË   r·   r<   r<   r=   Úp_pppragma_directiveC  s
     zCParser.p_pppragma_directivec                 C   ó0   t |ƒdkr|d gn|d |d g |d< dS )z‡ pppragma_directive_list : pppragma_directive
                                    | pppragma_directive_list pppragma_directive
        r„   r   rp   N©rH   r·   r<   r<   r=   Úp_pppragma_directive_listO  ó   0z!CParser.p_pppragma_directive_listc              
   C   sN   t g g g tjdg|  |d¡d�gg d�}| j||d |d |d d�|d< d	S )
zU function_definition : id_declarator declaration_list_opt compound_statement
        rj   r   rk   ©rx   r{   ry   ra   rz   r„   rÉ   ©r€   rd   rœ   r�   rp   N)r0   r   rs   rË   rŸ   ©r3   r¸   r€   r<   r<   r=   Úp_function_definition_1W  s   
ÿúüzCParser.p_function_definition_1c                 C   s.   |d }| j ||d |d |d d�|d< dS )zl function_definition : declaration_specifiers id_declarator declaration_list_opt compound_statement
        r   r„   rÉ   é   rÕ   rp   N)rŸ   rÖ   r<   r<   r=   Úp_function_definition_2i  s   üzCParser.p_function_definition_2c                 C   rº   )a_   statement   : labeled_statement
                        | expression_statement
                        | compound_statement
                        | selection_statement
                        | iteration_statement
                        | jump_statement
                        | pppragma_directive
                        | static_assert
        r   rp   Nr<   r·   r<   r<   r=   Úp_statementx  s   
zCParser.p_statementc                 C   sH   t |ƒdkrtj|d |d g |  |d¡d�|d< dS |d |d< dS )z} pragmacomp_or_statement     : pppragma_directive_list statement
                                        | statement
        rÉ   r   r„   ©Úblock_itemsrQ   rp   N)rH   r   ÚCompoundrË   r·   r<   r<   r=   Úp_pragmacomp_or_statement¯  s   
þz!CParser.p_pragmacomp_or_statementc                 C   s¼   |d }|d du rN|d }t jt jt jf}t|ƒdkr@t|d |ƒr@t jd|d |d |d |d	 |d dd|d jd
�	g}n| j|t	ddd�gdd�}n
| j||d dd�}||d< dS )z˜ decl_body : declaration_specifiers init_declarator_list_opt
                      | declaration_specifiers_no_type id_init_declarator_list_opt
        r   r„   Nra   rp   rx   r{   ry   rz   r‰   rš   Tr›   )
r   r�   rŽ   rŒ   rH   rb   r�   rQ   r™   r0   )r3   r¸   r€   ÚtyÚs_u_or_er‘   r<   r<   r=   Úp_decl_bodyÃ  s6   
÷ýýzCParser.p_decl_bodyc                 C   rº   )z& declaration : decl_body SEMI
        r   rp   Nr<   r·   r<   r<   r=   Úp_declaration   rÃ   zCParser.p_declarationc                 C   s,   t |ƒdkr
|d n|d |d  |d< dS )zj declaration_list    : declaration
                                | declaration_list declaration
        r„   r   rp   NrÑ   r·   r<   r<   r=   Úp_declaration_list	  ó   ,zCParser.p_declaration_listc                 C   ó   |   |d |d d¡|d< dS )z] declaration_specifiers_no_type  : type_qualifier declaration_specifiers_no_type_opt
        r„   r   rx   rp   N©r�   r·   r<   r<   r=   Ú"p_declaration_specifiers_no_type_1  ó   z*CParser.p_declaration_specifiers_no_type_1c                 C   rå   )zf declaration_specifiers_no_type  : storage_class_specifier declaration_specifiers_no_type_opt
        r„   r   ry   rp   Nræ   r·   r<   r<   r=   Ú"p_declaration_specifiers_no_type_2  rè   z*CParser.p_declaration_specifiers_no_type_2c                 C   rå   )za declaration_specifiers_no_type  : function_specifier declaration_specifiers_no_type_opt
        r„   r   rz   rp   Nræ   r·   r<   r<   r=   Ú"p_declaration_specifiers_no_type_3  rè   z*CParser.p_declaration_specifiers_no_type_3c                 C   rå   )z_ declaration_specifiers_no_type  : atomic_specifier declaration_specifiers_no_type_opt
        r„   r   ra   rp   Nræ   r·   r<   r<   r=   Ú"p_declaration_specifiers_no_type_4%  rè   z*CParser.p_declaration_specifiers_no_type_4c                 C   rå   )zb declaration_specifiers_no_type  : alignment_specifier declaration_specifiers_no_type_opt
        r„   r   r{   rp   Nræ   r·   r<   r<   r=   Ú"p_declaration_specifiers_no_type_5*  rè   z*CParser.p_declaration_specifiers_no_type_5c                 C   ó"   | j |d |d ddd�|d< dS )zI declaration_specifiers  : declaration_specifiers type_qualifier
        r   r„   rx   T©rE   rp   Nræ   r·   r<   r<   r=   Úp_declaration_specifiers_1/  ó   "z"CParser.p_declaration_specifiers_1c                 C   rí   )zR declaration_specifiers  : declaration_specifiers storage_class_specifier
        r   r„   ry   Trî   rp   Nræ   r·   r<   r<   r=   Úp_declaration_specifiers_24  rð   z"CParser.p_declaration_specifiers_2c                 C   rí   )zM declaration_specifiers  : declaration_specifiers function_specifier
        r   r„   rz   Trî   rp   Nræ   r·   r<   r<   r=   Úp_declaration_specifiers_39  rð   z"CParser.p_declaration_specifiers_3c                 C   rí   )zS declaration_specifiers  : declaration_specifiers type_specifier_no_typeid
        r   r„   ra   Trî   rp   Nræ   r·   r<   r<   r=   Úp_declaration_specifiers_4>  rð   z"CParser.p_declaration_specifiers_4c                 C   ó   |   d|d d¡|d< dS )z2 declaration_specifiers  : type_specifier
        Nr   ra   rp   ræ   r·   r<   r<   r=   Úp_declaration_specifiers_5C  ó   z"CParser.p_declaration_specifiers_5c                 C   rí   )zQ declaration_specifiers  : declaration_specifiers_no_type type_specifier
        r   r„   ra   Trî   rp   Nræ   r·   r<   r<   r=   Úp_declaration_specifiers_6H  rð   z"CParser.p_declaration_specifiers_6c                 C   rí   )zN declaration_specifiers  : declaration_specifiers alignment_specifier
        r   r„   r{   Trî   rp   Nræ   r·   r<   r<   r=   Úp_declaration_specifiers_7M  rð   z"CParser.p_declaration_specifiers_7c                 C   rº   )a   storage_class_specifier : AUTO
                                    | REGISTER
                                    | STATIC
                                    | EXTERN
                                    | TYPEDEF
                                    | _THREAD_LOCAL
        r   rp   Nr<   r·   r<   r<   r=   Úp_storage_class_specifierR  ó   z!CParser.p_storage_class_specifierc                 C   rº   )zR function_specifier  : INLINE
                                | _NORETURN
        r   rp   Nr<   r·   r<   r<   r=   Úp_function_specifier\  r¼   zCParser.p_function_specifierc                 C   ó$   t j|d g|  |d¡d�|d< dS )a+   type_specifier_no_typeid  : VOID
                                      | _BOOL
                                      | CHAR
                                      | SHORT
                                      | INT
                                      | LONG
                                      | FLOAT
                                      | DOUBLE
                                      | _COMPLEX
                                      | SIGNED
                                      | UNSIGNED
                                      | __INT128
        r   rk   rp   N©r   rs   rË   r·   r<   r<   r=   Úp_type_specifier_no_typeidb  s   $z"CParser.p_type_specifier_no_typeidc                 C   rº   )zó type_specifier  : typedef_name
                            | enum_specifier
                            | struct_or_union_specifier
                            | type_specifier_no_typeid
                            | atomic_specifier
        r   rp   Nr<   r·   r<   r<   r=   Úp_type_specifierr  s   zCParser.p_type_specifierc                 C   s    |d }|j  d¡ ||d< dS )z= atomic_specifier  : _ATOMIC LPAREN type_name RPAREN
        rÉ   Ú_Atomicrp   N)rr   rE   )r3   r¸   Útypr<   r<   r=   Úp_atomic_specifier|  s   zCParser.p_atomic_specifierc                 C   rº   )z• type_qualifier  : CONST
                            | RESTRICT
                            | VOLATILE
                            | _ATOMIC
        r   rp   Nr<   r·   r<   r<   r=   Úp_type_qualifierƒ  s   zCParser.p_type_qualifierc                 C   ó0   t |ƒdkr|d |d g n|d g|d< dS )z„ init_declarator_list    : init_declarator
                                    | init_declarator_list COMMA init_declarator
        rØ   r   rÉ   rp   NrÑ   r·   r<   r<   r=   Úp_init_declarator_list‹  rÓ   zCParser.p_init_declarator_listc                 C   ó,   t |d t|ƒdkr|d ndd�|d< dS )zb init_declarator : declarator
                            | declarator EQUALS initializer
        r   r„   rÉ   Nrš   rp   ©r0   rH   r·   r<   r<   r=   Úp_init_declarator”  rä   zCParser.p_init_declaratorc                 C   r  )z� id_init_declarator_list    : id_init_declarator
                                       | id_init_declarator_list COMMA init_declarator
        rØ   r   rÉ   rp   NrÑ   r·   r<   r<   r=   Úp_id_init_declarator_listš  rÓ   z!CParser.p_id_init_declarator_listc                 C   r  )zn id_init_declarator : id_declarator
                               | id_declarator EQUALS initializer
        r   r„   rÉ   Nrš   rp   r  r·   r<   r<   r=   Úp_id_init_declarator   rä   zCParser.p_id_init_declaratorc                 C   rí   )zY specifier_qualifier_list    : specifier_qualifier_list type_specifier_no_typeid
        r   r„   ra   Trî   rp   Nræ   r·   r<   r<   r=   Úp_specifier_qualifier_list_1¨  rð   z$CParser.p_specifier_qualifier_list_1c                 C   rí   )zO specifier_qualifier_list    : specifier_qualifier_list type_qualifier
        r   r„   rx   Trî   rp   Nræ   r·   r<   r<   r=   Úp_specifier_qualifier_list_2­  rð   z$CParser.p_specifier_qualifier_list_2c                 C   rô   )z4 specifier_qualifier_list  : type_specifier
        Nr   ra   rp   ræ   r·   r<   r<   r=   Úp_specifier_qualifier_list_3²  rö   z$CParser.p_specifier_qualifier_list_3c                 C   s$   t |d g g |d gg d�|d< dS )zH specifier_qualifier_list  : type_qualifier_list type_specifier
        r   r„   rÔ   rp   N©r0   r·   r<   r<   r=   Úp_specifier_qualifier_list_4·  s   $z$CParser.p_specifier_qualifier_list_4c                 C   s    t g |d gg g g d�|d< dS )z9 specifier_qualifier_list  : alignment_specifier
        r   rÔ   rp   Nr  r·   r<   r<   r=   Úp_specifier_qualifier_list_5¼  s    z$CParser.p_specifier_qualifier_list_5c                 C   rå   )zR specifier_qualifier_list  : specifier_qualifier_list alignment_specifier
        r   r„   r{   rp   Nræ   r·   r<   r<   r=   Úp_specifier_qualifier_list_6Á  rè   z$CParser.p_specifier_qualifier_list_6c                 C   s0   |   |d ¡}||d d|  |d¡d�|d< dS )z{ struct_or_union_specifier   : struct_or_union ID
                                        | struct_or_union TYPEID
        r   r„   N©rP   r‘   rQ   rp   )r¢   rË   ©r3   r¸   Úklassr<   r<   r=   Úp_struct_or_union_specifier_1É  s   
ýz%CParser.p_struct_or_union_specifier_1c                 C   sZ   |   |d ¡}t|ƒdkr|dg |  |d¡d�|d< dS |d|d |  |d¡d�|d< dS )z³ struct_or_union_specifier : struct_or_union brace_open struct_declaration_list brace_close
                                      | struct_or_union brace_open brace_close
        r   rØ   Nr„   r  rp   rÉ   ©r¢   rH   rË   r  r<   r<   r=   Úp_struct_or_union_specifier_2Ô  s   
ý
ýz%CParser.p_struct_or_union_specifier_2c                 C   sb   |   |d ¡}t|ƒdkr||d g |  |d¡d�|d< dS ||d |d |  |d¡d�|d< dS )a…   struct_or_union_specifier   : struct_or_union ID brace_open struct_declaration_list brace_close
                                        | struct_or_union ID brace_open brace_close
                                        | struct_or_union TYPEID brace_open struct_declaration_list brace_close
                                        | struct_or_union TYPEID brace_open brace_close
        r   rÈ   r„   r  rp   rØ   Nr  r  r<   r<   r=   Úp_struct_or_union_specifier_3æ  s   
ý
ýz%CParser.p_struct_or_union_specifier_3c                 C   rº   )zF struct_or_union : STRUCT
                            | UNION
        r   rp   Nr<   r·   r<   r<   r=   Úp_struct_or_unionù  r¼   zCParser.p_struct_or_unionc                 C   s<   t |ƒdkr|d pg |d< dS |d |d pg  |d< dS )z� struct_declaration_list     : struct_declaration
                                        | struct_declaration_list struct_declaration
        r„   r   rp   NrÑ   r·   r<   r<   r=   Úp_struct_declaration_list  s   z!CParser.p_struct_declaration_listc                 C   s¬   |d }d|d vsJ ‚|d dur| j ||d d�}n4t|d ƒdkrD|d d }t|tjƒr3|}nt |¡}| j |t|d	�gd�}n| j |tddd
�gd�}||d< dS )zW struct_declaration : specifier_qualifier_list struct_declarator_list_opt SEMI
        r   r‚   ry   r„   N©r€   r‘   ra   rp   ©rd   rš   )r™   rH   rb   r   ÚNoders   r0   )r3   r¸   r€   r‘   ÚnodeÚ	decl_typer<   r<   r=   Úp_struct_declaration_1
  s*   þ

þ	þzCParser.p_struct_declaration_1c                 C   ó   d|d< dS )z# struct_declaration : SEMI
        Nrp   r<   r·   r<   r<   r=   Úp_struct_declaration_20  rÆ   zCParser.p_struct_declaration_2c                 C   r¿   )z1 struct_declaration : pppragma_directive
        r   rp   Nr<   r·   r<   r<   r=   Úp_struct_declaration_35  rÁ   zCParser.p_struct_declaration_3c                 C   r  )zŠ struct_declarator_list  : struct_declarator
                                    | struct_declarator_list COMMA struct_declarator
        rØ   r   rÉ   rp   NrÑ   r·   r<   r<   r=   Úp_struct_declarator_list:  rÓ   z CParser.p_struct_declarator_listc                 C   s   |d ddœ|d< dS )z( struct_declarator : declarator
        r   N©rd   rƒ   rp   r<   r·   r<   r<   r=   Úp_struct_declarator_1C  s   zCParser.p_struct_declarator_1c                 C   sH   t |ƒdkr|d |d dœ|d< dS t dddd¡|d dœ|d< dS )z€ struct_declarator   : declarator COLON constant_expression
                                | COLON constant_expression
        rÉ   r   r%  rp   Nr„   )rH   r   rc   r·   r<   r<   r=   Úp_struct_declarator_2H  s   "zCParser.p_struct_declarator_2c                 C   s"   t  |d d|  |d¡¡|d< dS )zM enum_specifier  : ENUM ID
                            | ENUM TYPEID
        r„   Nr   rp   ©r   rŒ   rË   r·   r<   r<   r=   Úp_enum_specifier_1Q  s   "zCParser.p_enum_specifier_1c                 C   s"   t  d|d |  |d¡¡|d< dS )zG enum_specifier  : ENUM brace_open enumerator_list brace_close
        NrÉ   r   rp   r(  r·   r<   r<   r=   Úp_enum_specifier_2W  rð   zCParser.p_enum_specifier_2c                 C   ó&   t  |d |d |  |d¡¡|d< dS )z› enum_specifier  : ENUM ID brace_open enumerator_list brace_close
                            | ENUM TYPEID brace_open enumerator_list brace_close
        r„   rØ   r   rp   Nr(  r·   r<   r<   r=   Úp_enum_specifier_3\  s   &zCParser.p_enum_specifier_3c                 C   sl   t |ƒdkrt |d g|d j¡|d< dS t |ƒdkr$|d |d< dS |d j |d ¡ |d |d< dS )z™ enumerator_list : enumerator
                            | enumerator_list COMMA
                            | enumerator_list COMMA enumerator
        r„   r   rp   rÉ   N)rH   r   ÚEnumeratorListrQ   ÚenumeratorsrE   r·   r<   r<   r=   Úp_enumerator_listb  s    zCParser.p_enumerator_listc                 C   ó    t  |d |  |d¡¡|d< dS )z� alignment_specifier  : _ALIGNAS LPAREN type_name RPAREN
                                 | _ALIGNAS LPAREN constant_expression RPAREN
        rÉ   r   rp   N)r   ÚAlignasrË   r·   r<   r<   r=   Úp_alignment_specifiero  s    zCParser.p_alignment_specifierc                 C   sb   t |ƒdkrt |d d|  |d¡¡}nt |d |d |  |d¡¡}|  |j|j¡ ||d< dS )zR enumerator  : ID
                        | ID EQUALS constant_expression
        r„   r   NrÉ   rp   )rH   r   Ú
EnumeratorrË   rS   rP   rQ   )r3   r¸   Ú
enumeratorr<   r<   r=   Úp_enumeratoru  s   
þ
þzCParser.p_enumeratorc                 C   rº   )zQ declarator  : id_declarator
                        | typeid_declarator
        r   rp   Nr<   r·   r<   r<   r=   Úp_declarator…  r¼   zCParser.p_declarator)rn   ÚID)ÚtypeidÚTYPEID)Útypeid_noparenr9  c                 C   rº   )z1 xxx_declarator  : direct_xxx_declarator
        r   rp   Nr<   r·   r<   r<   r=   Úp_xxx_declarator_1‹  r¼   zCParser.p_xxx_declarator_1c                 C   ó   |   |d |d ¡|d< dS )z9 xxx_declarator  : pointer direct_xxx_declarator
        r„   r   rp   N©ri   r·   r<   r<   r=   Úp_xxx_declarator_2‘  ó   zCParser.p_xxx_declarator_2c              	   C   s(   t j|d ddd|  |d¡d�|d< dS )z' direct_xxx_declarator   : yyy
        r   Nr†   rp   )r   rc   rË   r·   r<   r<   r=   Úp_direct_xxx_declarator_1—  s   
ûz!CParser.p_direct_xxx_declarator_1c                 C   rº   )z@ direct_xxx_declarator   : LPAREN xxx_declarator RPAREN
        r„   rp   Nr<   r·   r<   r<   r=   Úp_direct_xxx_declarator_2¢  r¼   z!CParser.p_direct_xxx_declarator_2c                 C   sf   t |ƒdkr
|d ng pg }tjdt |ƒdkr|d n|d ||d jd�}| j|d |d�|d< dS )	z} direct_xxx_declarator   : direct_xxx_declarator LBRACKET type_qualifier_list_opt assignment_expression_opt RBRACKET
        rÈ   rÉ   NrØ   r   ©ra   ÚdimÚ	dim_qualsrQ   ©rd   re   rp   )rH   r   Ú	ArrayDeclrQ   ri   )r3   r¸   rr   Úarrr<   r<   r=   Úp_direct_xxx_declarator_3¨  s   üz!CParser.p_direct_xxx_declarator_3c                 C   s^   dd„ |d |d fD ƒ}dd„ |D ƒ}t jd|d ||d jd	�}| j|d |d
�|d< dS )zÿ direct_xxx_declarator   : direct_xxx_declarator LBRACKET STATIC type_qualifier_list_opt assignment_expression RBRACKET
                                    | direct_xxx_declarator LBRACKET type_qualifier_list STATIC assignment_expression RBRACKET
        c                 S   ó    g | ]}t |tƒr|n|g‘qS r<   ©rb   Úlist©rm   Úitemr<   r<   r=   ro   ¿  ó    ÿz5CParser.p_direct_xxx_declarator_4.<locals>.<listcomp>rÉ   rØ   c                 S   ó"   g | ]}|D ]}|d ur|‘qqS rD   r<   ©rm   Úsublistrx   r<   r<   r=   ro   Á  ó    ÿNrÈ   r   rB  rE  rp   ©r   rF  rQ   ri   )r3   r¸   Úlisted_qualsrD  rG  r<   r<   r=   Úp_direct_xxx_declarator_4·  s   ÿüz!CParser.p_direct_xxx_declarator_4c              	   C   sZ   t jdt  |d |  |d¡¡|d dur|d ng |d jd�}| j|d |d�|d< dS )zi direct_xxx_declarator   : direct_xxx_declarator LBRACKET type_qualifier_list_opt TIMES RBRACKET
        NrØ   rÉ   r   rB  rE  rp   ©r   rF  r7  rË   rQ   ri   ©r3   r¸   rG  r<   r<   r=   Úp_direct_xxx_declarator_5Í  s   üz!CParser.p_direct_xxx_declarator_5c                 C   sz   t j|d d|d jd�}|  ¡ jdkr0|jdur0|jjD ]}t|t jƒr' n	|  	|j
|j¡ q| j|d |d�|d< dS )z¹ direct_xxx_declarator   : direct_xxx_declarator LPAREN parameter_type_list RPAREN
                                    | direct_xxx_declarator LPAREN identifier_list_opt RPAREN
        rÉ   Nr   ©Úargsra   rQ   ÚLBRACErE  rp   )r   rt   rQ   r`   ra   rZ  Úparamsrb   ÚEllipsisParamrS   rP   ri   )r3   r¸   ÚfuncÚparamr<   r<   r=   Úp_direct_xxx_declarator_6Ù  s   ý
z!CParser.p_direct_xxx_declarator_6c                 C   st   |   |d¡}tj|d pg d|d�}t|ƒdkr4|d }|jdur)|j}|jdus!||_|d |d< dS ||d< dS )zm pointer : TIMES type_qualifier_list_opt
                    | TIMES type_qualifier_list_opt pointer
        r   r„   N)rr   ra   rQ   rÉ   rp   )rË   r   ÚPtrDeclrH   ra   )r3   r¸   rQ   Únested_typeÚ	tail_typer<   r<   r=   Ú	p_pointerö  s   

ÿzCParser.p_pointerc                 C   rÐ   )zs type_qualifier_list : type_qualifier
                                | type_qualifier_list type_qualifier
        r„   r   rp   NrÑ   r·   r<   r<   r=   Úp_type_qualifier_list  rÓ   zCParser.p_type_qualifier_listc                 C   s:   t |ƒdkr|d j t |  |d¡¡¡ |d |d< dS )zn parameter_type_list : parameter_list
                                | parameter_list COMMA ELLIPSIS
        r„   r   rÉ   rp   N)rH   r\  rE   r   r]  rË   r·   r<   r<   r=   Úp_parameter_type_list  s   zCParser.p_parameter_type_listc                 C   óP   t |ƒdkrt |d g|d j¡|d< dS |d j |d ¡ |d |d< dS )zz parameter_list  : parameter_declaration
                            | parameter_list COMMA parameter_declaration
        r„   r   rp   rÉ   N©rH   r   Ú	ParamListrQ   r\  rE   r·   r<   r<   r=   Úp_parameter_list#  ó    zCParser.p_parameter_listc                 C   sT   |d }|d st jdg|  |d¡d�g|d< | j|t|d d�gd�d |d< d	S )
zŸ parameter_declaration   : declaration_specifiers id_declarator
                                    | declaration_specifiers typeid_noparen_declarator
        r   ra   rj   rk   r„   r  r  rp   N)r   rs   rË   r™   r0   rÖ   r<   r<   r=   Úp_parameter_declaration_17  s   
ÿþþz!CParser.p_parameter_declaration_1c              
   C   sâ   |d }|d st jdg|  |d¡d�g|d< t|d ƒdkrGt|d d jƒdkrG|  |d d jd ¡rG| j|t|d dd	�gd
�d }n$t jd|d d|d pYt  	dddd¡|  |d¡d�}|d }|  
||¡}||d< dS )zR parameter_declaration   : declaration_specifiers abstract_declarator_opt
        r   ra   rj   rk   rK   rp   r„   Nrš   r  r   rx   ©rP   rr   r‡   ra   rQ   )r   rs   rË   rH   rl   rW   r™   r0   ÚTypenamerc   rw   )r3   r¸   r€   rd   ru   r<   r<   r=   Úp_parameter_declaration_2C  s0   
ÿ&ÿþþ
ûz!CParser.p_parameter_declaration_2c                 C   rg  )ze identifier_list : identifier
                            | identifier_list COMMA identifier
        r„   r   rp   rÉ   Nrh  r·   r<   r<   r=   Úp_identifier_listc  rk  zCParser.p_identifier_listc                 C   rº   )z- initializer : assignment_expression
        r   rp   Nr<   r·   r<   r<   r=   Úp_initializer_1m  rÃ   zCParser.p_initializer_1c                 C   s8   |d du rt  g |  |d¡¡|d< dS |d |d< dS )z‹ initializer : brace_open initializer_list_opt brace_close
                        | brace_open initializer_list COMMA brace_close
        r„   Nr   rp   )r   ÚInitListrË   r·   r<   r<   r=   Úp_initializer_2r  s   zCParser.p_initializer_2c                 C   s˜   t |ƒdkr(|d du r|d n	t |d |d ¡}t |g|d j¡|d< dS |d du r2|d n	t |d |d ¡}|d j |¡ |d |d< dS )z� initializer_list    : designation_opt initializer
                                | initializer_list COMMA designation_opt initializer
        rÉ   r   Nr„   rp   rØ   )rH   r   ÚNamedInitializerrr  rQ   ÚexprsrE   )r3   r¸   rˆ   r<   r<   r=   Úp_initializer_list{  s   ((zCParser.p_initializer_listc                 C   rº   )z. designation : designator_list EQUALS
        r   rp   Nr<   r·   r<   r<   r=   Úp_designation‡  rÃ   zCParser.p_designationc                 C   rÐ   )z_ designator_list : designator
                            | designator_list designator
        r„   r   rp   NrÑ   r·   r<   r<   r=   Úp_designator_list�  rÓ   zCParser.p_designator_listc                 C   rº   )zi designator  : LBRACKET constant_expression RBRACKET
                        | PERIOD identifier
        r„   rp   Nr<   r·   r<   r<   r=   Úp_designator•  r¼   zCParser.p_designatorc              
   C   s\   t jd|d d dd… d|d pt  dddd¡|  |d¡d�}|  ||d d ¡|d< dS )	zH type_name   : specifier_qualifier_list abstract_declarator_opt
        r   r   rx   Nr„   rm  ra   rp   )r   rn  rc   rË   rw   )r3   r¸   ru   r<   r<   r=   Úp_type_name›  s   
ûzCParser.p_type_namec                 C   s*   t  dddd¡}| j||d d�|d< dS )z+ abstract_declarator     : pointer
        Nr   rE  rp   )r   rc   ri   )r3   r¸   Ú	dummytyper<   r<   r=   Úp_abstract_declarator_1§  s
   þzCParser.p_abstract_declarator_1c                 C   r<  )zF abstract_declarator     : pointer direct_abstract_declarator
        r„   r   rp   Nr=  r·   r<   r<   r=   Úp_abstract_declarator_2¯  s   zCParser.p_abstract_declarator_2c                 C   rº   )z> abstract_declarator     : direct_abstract_declarator
        r   rp   Nr<   r·   r<   r<   r=   Úp_abstract_declarator_3´  rÃ   zCParser.p_abstract_declarator_3c                 C   rº   )zA direct_abstract_declarator  : LPAREN abstract_declarator RPAREN r„   rp   Nr<   r·   r<   r<   r=   Úp_direct_abstract_declarator_1¾  ó   z&CParser.p_direct_abstract_declarator_1c                 C   s6   t jd|d g |d jd�}| j|d |d�|d< dS )zn direct_abstract_declarator  : direct_abstract_declarator LBRACKET assignment_expression_opt RBRACKET
        NrÉ   r   rB  rE  rp   rS  rW  r<   r<   r=   Úp_direct_abstract_declarator_2Â  s   üz&CParser.p_direct_abstract_declarator_2c                 C   sb   t |ƒdkr
|d ng pg }tjt dddd¡t |ƒdkr!|d n|d ||  |d¡d�|d< dS )zk direct_abstract_declarator  : LBRACKET type_qualifier_list_opt assignment_expression_opt RBRACKET
        rØ   r„   NrÉ   r   rB  rp   )rH   r   rF  rc   rË   )r3   r¸   rr   r<   r<   r=   Úp_direct_abstract_declarator_3Í  s   
üz&CParser.p_direct_abstract_declarator_3c              	   C   sF   t jdt  |d |  |d¡¡g |d jd�}| j|d |d�|d< dS )zZ direct_abstract_declarator  : direct_abstract_declarator LBRACKET TIMES RBRACKET
        NrÉ   r   rB  rE  rp   rV  rW  r<   r<   r=   Úp_direct_abstract_declarator_4×  s   üz&CParser.p_direct_abstract_declarator_4c              	   C   sB   t jt  dddd¡t  |d |  |d¡¡g |  |d¡d�|d< dS )z? direct_abstract_declarator  : LBRACKET TIMES RBRACKET
        NrÉ   r   rB  rp   )r   rF  rc   r7  rË   r·   r<   r<   r=   Úp_direct_abstract_declarator_5â  s   
üz&CParser.p_direct_abstract_declarator_5c                 C   s4   t j|d d|d jd�}| j|d |d�|d< dS )zh direct_abstract_declarator  : direct_abstract_declarator LPAREN parameter_type_list_opt RPAREN
        rÉ   Nr   rY  rE  rp   )r   rt   rQ   ri   )r3   r¸   r^  r<   r<   r=   Úp_direct_abstract_declarator_6ë  s   ýz&CParser.p_direct_abstract_declarator_6c                 C   s0   t j|d t  dddd¡|  |d¡d�|d< dS )zM direct_abstract_declarator  : LPAREN parameter_type_list_opt RPAREN
        r„   Nr   rY  rp   )r   rt   rc   rË   r·   r<   r<   r=   Úp_direct_abstract_declarator_7õ  s
   
ýz&CParser.p_direct_abstract_declarator_7c                 C   sZ   dd„ |d |d fD ƒ}dd„ |D ƒ}t jt  dddd¡|d ||  |d¡d	�|d
< dS )zÜ direct_abstract_declarator  : LBRACKET STATIC type_qualifier_list_opt assignment_expression RBRACKET
                                         | LBRACKET type_qualifier_list STATIC assignment_expression RBRACKET
        c                 S   rI  r<   rJ  rL  r<   r<   r=   ro     rN  z:CParser.p_direct_abstract_declarator_8.<locals>.<listcomp>r„   rÉ   c                 S   rO  rD   r<   rP  r<   r<   r=   ro     rR  NrØ   r   rB  rp   )r   rF  rc   rË   )r3   r¸   rT  rr   r<   r<   r=   Úp_direct_abstract_declarator_8ý  s   ÿ
üz&CParser.p_direct_abstract_declarator_8c                 C   s(   t |d tƒr|d n|d g|d< dS )zG block_item  : declaration
                        | statement
        r   rp   NrJ  r·   r<   r<   r=   Úp_block_item  ó   (zCParser.p_block_itemc                 C   s:   t |ƒdks|d dgkr|d n|d |d  |d< dS )z_ block_item_list : block_item
                            | block_item_list block_item
        r„   Nr   rp   rÑ   r·   r<   r<   r=   Úp_block_item_list  s   :zCParser.p_block_item_listc                 C   s"   t j|d |  |d¡d�|d< dS )zA compound_statement : brace_open block_item_list_opt brace_close r„   r   rÛ   rp   N)r   rÝ   rË   r·   r<   r<   r=   Úp_compound_statement_1  s   
þzCParser.p_compound_statement_1c                 C   s&   t  |d |d |  |d¡¡|d< dS )z6 labeled_statement : ID COLON pragmacomp_or_statement r   rÉ   rp   N)r   ÚLabelrË   r·   r<   r<   r=   Úp_labeled_statement_1#  ó   &zCParser.p_labeled_statement_1c                 C   s(   t  |d |d g|  |d¡¡|d< dS )zL labeled_statement : CASE constant_expression COLON pragmacomp_or_statement r„   rØ   r   rp   N)r   ÚCaserË   r·   r<   r<   r=   Úp_labeled_statement_2'  ó   (zCParser.p_labeled_statement_2c                 C   s"   t  |d g|  |d¡¡|d< dS )z; labeled_statement : DEFAULT COLON pragmacomp_or_statement rÉ   r   rp   N)r   ÚDefaultrË   r·   r<   r<   r=   Úp_labeled_statement_3+  s   "zCParser.p_labeled_statement_3c              	   C   s0   t  |d t  |  |d¡¡|  |d¡¡|d< dS )z labeled_statement : ID COLON r   rp   N)r   rŒ  ÚEmptyStatementrË   r·   r<   r<   r=   Úp_labeled_statement_4/  s   0zCParser.p_labeled_statement_4c              	   C   s2   t  |d t  |  |d¡¡g|  |d¡¡|d< dS )z4 labeled_statement : CASE constant_expression COLON r„   r   rp   N)r   r�  r”  rË   r·   r<   r<   r=   Úp_labeled_statement_53  ó   2zCParser.p_labeled_statement_5c                 C   s,   t  t  |  |d¡¡g|  |d¡¡|d< dS )z# labeled_statement : DEFAULT COLON r   rp   N)r   r’  r”  rË   r·   r<   r<   r=   Úp_labeled_statement_67  ó   ,zCParser.p_labeled_statement_6c              	   C   s(   t  |d |d d|  |d¡¡|d< dS )zK selection_statement : IF LPAREN expression RPAREN pragmacomp_or_statement rÉ   rÈ   Nr   rp   ©r   ÚIfrË   r·   r<   r<   r=   Úp_selection_statement_1;  r‘  zCParser.p_selection_statement_1c              	   C   s,   t  |d |d |d |  |d¡¡|d< dS )zZ selection_statement : IF LPAREN expression RPAREN statement ELSE pragmacomp_or_statement rÉ   rÈ   é   r   rp   Nrš  r·   r<   r<   r=   Úp_selection_statement_2?  r™  zCParser.p_selection_statement_2c              	   C   s*   t t |d |d |  |d¡¡ƒ|d< dS )zO selection_statement : SWITCH LPAREN expression RPAREN pragmacomp_or_statement rÉ   rÈ   r   rp   N)r	   r   ÚSwitchrË   r·   r<   r<   r=   Úp_selection_statement_3C  s   ÿzCParser.p_selection_statement_3c                 C   r+  )zN iteration_statement : WHILE LPAREN expression RPAREN pragmacomp_or_statement rÉ   rÈ   r   rp   N)r   ÚWhilerË   r·   r<   r<   r=   Úp_iteration_statement_1H  rŽ  zCParser.p_iteration_statement_1c                 C   r+  )zV iteration_statement : DO pragmacomp_or_statement WHILE LPAREN expression RPAREN SEMI rÈ   r„   r   rp   N)r   ÚDoWhilerË   r·   r<   r<   r=   Úp_iteration_statement_2L  rŽ  zCParser.p_iteration_statement_2c              
   C   s2   t  |d |d |d |d |  |d¡¡|d< dS )zx iteration_statement : FOR LPAREN expression_opt SEMI expression_opt SEMI expression_opt RPAREN pragmacomp_or_statement rÉ   rÈ   r�  é	   r   rp   N)r   ÚForrË   r·   r<   r<   r=   Úp_iteration_statement_3P  r—  zCParser.p_iteration_statement_3c              
   C   sB   t  t  |d |  |d¡¡|d |d |d |  |d¡¡|d< dS )zp iteration_statement : FOR LPAREN declaration expression_opt SEMI expression_opt RPAREN pragmacomp_or_statement rÉ   r   rØ   é   é   rp   N)r   r¦  ÚDeclListrË   r·   r<   r<   r=   Úp_iteration_statement_4T  s   ÿzCParser.p_iteration_statement_4c                 C   r0  )z  jump_statement  : GOTO ID SEMI r„   r   rp   N)r   ÚGotorË   r·   r<   r<   r=   Úp_jump_statement_1Y  ó    zCParser.p_jump_statement_1c                 C   ó   t  |  |d¡¡|d< dS )z jump_statement  : BREAK SEMI r   rp   N)r   ÚBreakrË   r·   r<   r<   r=   Úp_jump_statement_2]  ó   zCParser.p_jump_statement_2c                 C   r¯  )z! jump_statement  : CONTINUE SEMI r   rp   N)r   ÚContinuerË   r·   r<   r<   r=   Úp_jump_statement_3a  r²  zCParser.p_jump_statement_3c                 C   s0   t  t|ƒdkr|d nd|  |d¡¡|d< dS )z\ jump_statement  : RETURN expression SEMI
                            | RETURN SEMI
        rØ   r„   Nr   rp   )r   ÚReturnrH   rË   r·   r<   r<   r=   Úp_jump_statement_4e  rÓ   zCParser.p_jump_statement_4c                 C   s6   |d du rt  |  |d¡¡|d< dS |d |d< dS )z, expression_statement : expression_opt SEMI r   Nr„   rp   )r   r”  rË   r·   r<   r<   r=   Úp_expression_statementk  s   zCParser.p_expression_statementc                 C   sl   t |ƒdkr|d |d< dS t|d tjƒs$t |d g|d j¡|d< |d j |d ¡ |d |d< dS )zn expression  : assignment_expression
                        | expression COMMA assignment_expression
        r„   r   rp   rÉ   N)rH   rb   r   ÚExprListrQ   ru  rE   r·   r<   r<   r=   Úp_expressionr  s   zCParser.p_expressionc                 C   rº   )z: assignment_expression : LPAREN compound_statement RPAREN r„   rp   Nr<   r·   r<   r<   r=   Ú#p_parenthesized_compound_expression  r€  z+CParser.p_parenthesized_compound_expressionc                 C   rü   )z typedef_name : TYPEID r   rk   rp   Nrý   r·   r<   r<   r=   Úp_typedef_nameƒ  ó   $zCParser.p_typedef_namec                 C   óF   t |ƒdkr|d |d< dS t |d |d |d |d j¡|d< dS )z› assignment_expression   : conditional_expression
                                    | unary_expression assignment_operator assignment_expression
        r„   r   rp   rÉ   N)rH   r   Ú
AssignmentrQ   r·   r<   r<   r=   Úp_assignment_expression‡  ó   *zCParser.p_assignment_expressionc                 C   rº   )aÞ   assignment_operator : EQUALS
                                | XOREQUAL
                                | TIMESEQUAL
                                | DIVEQUAL
                                | MODEQUAL
                                | PLUSEQUAL
                                | MINUSEQUAL
                                | LSHIFTEQUAL
                                | RSHIFTEQUAL
                                | ANDEQUAL
                                | OREQUAL
        r   rp   Nr<   r·   r<   r<   r=   Úp_assignment_operator•  s   zCParser.p_assignment_operatorc                 C   rº   )z. constant_expression : conditional_expression r   rp   Nr<   r·   r<   r<   r=   Úp_constant_expression¤  r€  zCParser.p_constant_expressionc                 C   sF   t |ƒdkr|d |d< dS t |d |d |d |d j¡|d< dS )zœ conditional_expression  : binary_expression
                                    | binary_expression CONDOP expression COLON conditional_expression
        r„   r   rp   rÉ   rÈ   N)rH   r   Ú	TernaryOprQ   r·   r<   r<   r=   Úp_conditional_expression¨  rÀ  z CParser.p_conditional_expressionc                 C   r½  )ak   binary_expression   : cast_expression
                                | binary_expression TIMES binary_expression
                                | binary_expression DIVIDE binary_expression
                                | binary_expression MOD binary_expression
                                | binary_expression PLUS binary_expression
                                | binary_expression MINUS binary_expression
                                | binary_expression RSHIFT binary_expression
                                | binary_expression LSHIFT binary_expression
                                | binary_expression LT binary_expression
                                | binary_expression LE binary_expression
                                | binary_expression GE binary_expression
                                | binary_expression GT binary_expression
                                | binary_expression EQ binary_expression
                                | binary_expression NE binary_expression
                                | binary_expression AND binary_expression
                                | binary_expression OR binary_expression
                                | binary_expression XOR binary_expression
                                | binary_expression LAND binary_expression
                                | binary_expression LOR binary_expression
        r„   r   rp   rÉ   N)rH   r   ÚBinaryOprQ   r·   r<   r<   r=   Úp_binary_expression±  s   *zCParser.p_binary_expressionc                 C   rº   )z$ cast_expression : unary_expression r   rp   Nr<   r·   r<   r<   r=   Úp_cast_expression_1Ë  r€  zCParser.p_cast_expression_1c                 C   r+  )z; cast_expression : LPAREN type_name RPAREN cast_expression r„   rØ   r   rp   N)r   ÚCastrË   r·   r<   r<   r=   Úp_cast_expression_2Ï  rŽ  zCParser.p_cast_expression_2c                 C   rº   )z* unary_expression    : postfix_expression r   rp   Nr<   r·   r<   r<   r=   Úp_unary_expression_1Ó  r€  zCParser.p_unary_expression_1c                 C   s$   t  |d |d |d j¡|d< dS )z¸ unary_expression    : PLUSPLUS unary_expression
                                | MINUSMINUS unary_expression
                                | unary_operator cast_expression
        r   r„   rp   N©r   ÚUnaryOprQ   r·   r<   r<   r=   Úp_unary_expression_2×  s   $zCParser.p_unary_expression_2c                 C   s:   t  |d t|ƒdkr|d n|d |  |d¡¡|d< dS )z» unary_expression    : SIZEOF unary_expression
                                | SIZEOF LPAREN type_name RPAREN
                                | _ALIGNOF LPAREN type_name RPAREN
        r   rÉ   r„   rp   N)r   rÌ  rH   rË   r·   r<   r<   r=   Úp_unary_expression_3Þ  s
   
ýzCParser.p_unary_expression_3c                 C   rº   )zÏ unary_operator  : AND
                            | TIMES
                            | PLUS
                            | MINUS
                            | NOT
                            | LNOT
        r   rp   Nr<   r·   r<   r<   r=   Úp_unary_operatorè  rú   zCParser.p_unary_operatorc                 C   rº   )z* postfix_expression  : primary_expression r   rp   Nr<   r·   r<   r<   r=   Úp_postfix_expression_1ò  r€  zCParser.p_postfix_expression_1c                 C   s$   t  |d |d |d j¡|d< dS )zG postfix_expression  : postfix_expression LBRACKET expression RBRACKET r   rÉ   rp   N)r   ÚArrayRefrQ   r·   r<   r<   r=   Úp_postfix_expression_2ö  r¼  zCParser.p_postfix_expression_2c                 C   s4   t  |d t|ƒdkr|d nd|d j¡|d< dS )zœ postfix_expression  : postfix_expression LPAREN argument_expression_list RPAREN
                                | postfix_expression LPAREN RPAREN
        r   rÈ   rÉ   Nrp   )r   ÚFuncCallrH   rQ   r·   r<   r<   r=   Úp_postfix_expression_3ú  s   4zCParser.p_postfix_expression_3c                 C   s>   t  |d |  |d¡¡}t  |d |d ||d j¡|d< dS )zÿ postfix_expression  : postfix_expression PERIOD ID
                                | postfix_expression PERIOD TYPEID
                                | postfix_expression ARROW ID
                                | postfix_expression ARROW TYPEID
        rÉ   r   r„   rp   N)r   r7  rË   Ú	StructRefrQ   )r3   r¸   Úfieldr<   r<   r=   Úp_postfix_expression_4   s   &zCParser.p_postfix_expression_4c                 C   s(   t  d|d  |d |d j¡|d< dS )z{ postfix_expression  : postfix_expression PLUSPLUS
                                | postfix_expression MINUSMINUS
        r¸   r„   r   rp   NrË  r·   r<   r<   r=   Úp_postfix_expression_5	  r‰  zCParser.p_postfix_expression_5c                 C   s   t  |d |d ¡|d< dS )zÇ postfix_expression  : LPAREN type_name RPAREN brace_open initializer_list brace_close
                                | LPAREN type_name RPAREN brace_open initializer_list COMMA brace_close
        r„   rÈ   rp   N)r   ÚCompoundLiteralr·   r<   r<   r=   Úp_postfix_expression_6  r?  zCParser.p_postfix_expression_6c                 C   rº   )z" primary_expression  : identifier r   rp   Nr<   r·   r<   r<   r=   Úp_primary_expression_1  r€  zCParser.p_primary_expression_1c                 C   rº   )z  primary_expression  : constant r   rp   Nr<   r·   r<   r<   r=   Úp_primary_expression_2  r€  zCParser.p_primary_expression_2c                 C   rº   )zp primary_expression  : unified_string_literal
                                | unified_wstring_literal
        r   rp   Nr<   r·   r<   r<   r=   Úp_primary_expression_3  r¼   zCParser.p_primary_expression_3c                 C   rº   )z0 primary_expression  : LPAREN expression RPAREN r„   rp   Nr<   r·   r<   r<   r=   Úp_primary_expression_4#  r€  zCParser.p_primary_expression_4c                 C   sB   |   |d¡}t t |d |¡t |d |d g|¡|¡|d< dS )za primary_expression  : OFFSETOF LPAREN type_name COMMA offsetof_member_designator RPAREN
        r   rÉ   rÈ   rp   N)rË   r   rÓ  r7  r¸  )r3   r¸   rQ   r<   r<   r=   Úp_primary_expression_5'  s
   þzCParser.p_primary_expression_5c                 C   s’   t |ƒdkr|d |d< dS t |ƒdkr)t |d |d |d |d j¡|d< dS t |ƒdkrAt |d |d |d j¡|d< dS tdt |ƒ ƒ‚)	zì offsetof_member_designator : identifier
                                         | offsetof_member_designator PERIOD identifier
                                         | offsetof_member_designator LBRACKET expression RBRACKET
        r„   r   rp   rØ   rÉ   rÈ   z$Unexpected parsing state. len(p): %uN)rH   r   rÕ  rQ   rÑ  ÚNotImplementedErrorr·   r<   r<   r=   Úp_offsetof_member_designator/  s   *$z$CParser.p_offsetof_member_designatorc                 C   rg  )zœ argument_expression_list    : assignment_expression
                                        | argument_expression_list COMMA assignment_expression
        r„   r   rp   rÉ   N)rH   r   r¸  rQ   ru  rE   r·   r<   r<   r=   Úp_argument_expression_list=  rk  z"CParser.p_argument_expression_listc                 C   s    t  |d |  |d¡¡|d< dS )z identifier  : ID r   rp   N)r   r7  rË   r·   r<   r<   r=   Úp_identifierG  r®  zCParser.p_identifierc                 C   sš   d}d}|d dd… D ]}|dv r|d7 }q|dv r|d7 }qd}|dkr*t dƒ‚|d	kr2t d
ƒ‚d| d|  }t |d |d |  |d¡¡|d< dS )zÆ constant    : INT_CONST_DEC
                        | INT_CONST_OCT
                        | INT_CONST_HEX
                        | INT_CONST_BIN
                        | INT_CONST_CHAR
        rp   r   éýÿÿÿN©ÚlÚL)ÚuÚUr   z.Constant cannot have more than one u/U suffix.r„   z.Constant cannot have more than two l/L suffix.z	unsigned zlong rj   )Ú
ValueErrorr   ÚConstantrË   )r3   r¸   ÚuCountÚlCountÚxr•   Úprefixr<   r<   r=   Úp_constant_1K  s"   
€ÿzCParser.p_constant_1c                 C   sR   |d d dv rd}n|d d dv rd}nd}t  ||d |  |d¡¡|d< d	S )
zM constant    : FLOAT_CONST
                        | HEX_FLOAT_CONST
        r   rK   )ÚfÚFÚfloatrå  zlong doubleÚdoublerp   N©r   rë  rË   )r3   r¸   r•   r<   r<   r=   Úp_constant_2b  s   ÿzCParser.p_constant_2c                 C   s"   t  d|d |  |d¡¡|d< dS )z¿ constant    : CHAR_CONST
                        | WCHAR_CONST
                        | U8CHAR_CONST
                        | U16CHAR_CONST
                        | U32CHAR_CONST
        Úcharr   rp   Nrõ  r·   r<   r<   r=   Úp_constant_3p  s   ÿzCParser.p_constant_3c                 C   sf   t |ƒdkrt d|d |  |d¡¡|d< dS |d jdd… |d dd…  |d _|d |d< dS )z~ unified_string_literal  : STRING_LITERAL
                                    | unified_string_literal STRING_LITERAL
        r„   Ústringr   rp   NrK   )rH   r   rë  rË   Úvaluer·   r<   r<   r=   Úp_unified_string_literal  s   ÿ(z CParser.p_unified_string_literalc                 C   sj   t |ƒdkrt d|d |  |d¡¡|d< dS |d j ¡ dd… |d dd…  |d _|d |d< dS )a   unified_wstring_literal : WSTRING_LITERAL
                                    | U8STRING_LITERAL
                                    | U16STRING_LITERAL
                                    | U32STRING_LITERAL
                                    | unified_wstring_literal WSTRING_LITERAL
                                    | unified_wstring_literal U8STRING_LITERAL
                                    | unified_wstring_literal U16STRING_LITERAL
                                    | unified_wstring_literal U32STRING_LITERAL
        r„   rù  r   rp   NrK   )rH   r   rë  rË   rú  Úrstripr·   r<   r<   r=   Úp_unified_wstring_literalŠ  s   
ÿ,z!CParser.p_unified_wstring_literalc                 C   ó"   |d |d< |  d| d¡¡ dS )z  brace_open  :   LBRACE
        r   rp   N©Ú
set_linenoÚlinenor·   r<   r<   r=   Úp_brace_open›  ó   zCParser.p_brace_openc                 C   rþ  )z  brace_close :   RBRACE
        r   rp   Nrÿ  r·   r<   r<   r=   Úp_brace_close¡  r  zCParser.p_brace_closec                 C   r!  )zempty : Nrp   r<   r·   r<   r<   r=   Úp_empty§  s   zCParser.p_emptyc                 C   sB   |r|   d|j | j|j| j |¡d�¡ d S |   d| jj¡ d S )Nz
before: %s)r  r[   zAt end of input)rN   rú  rX   r  r+   Úfind_tok_columnr@   r·   r<   r<   r=   Úp_error«  s   
ÿþzCParser.p_errorN)r   F)F)´Ú__name__Ú
__module__Ú__qualname__r   r>   rB   rG   rJ   rR   rS   rW   r'   r(   r)   r*   r`   ri   rw   r�   r™   rŸ   r¢   Ú
precedencer¹   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  r  r	  r
  r  r  r  r  r  r  r  r  r  r  r  r   r"  r#  r$  r&  r'  r)  r*  r,  r/  r2  r5  r6  r   r;  r>  r@  rA  rH  rU  rX  r`  rd  re  rf  rj  rl  ro  rp  rq  rs  rv  rw  rx  ry  rz  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Á  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      s~   
øo	

	)2,Y	
	7=	

		&		















	 
	

	
	

	
r   N)Úplyr   r   r   Úc_lexerr   Ú	plyparserr   r   r   r   Úast_transformsr	   r
   r   r<   r<   r<   r=   Ú<module>   s   