HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: sport3497 (1034)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib64/python3.10/site-packages/pycparser/__pycache__/c_parser.cpython-310.pyc
o

�h*"�@sdddlmZddlmZddlmZddlmZmZm	Z	m
Z
ddlmZm
Z
e
Gdd�de��ZdS)	�)�yacc)�c_ast)�CLexer)�	PLYParser�
ParseError�
parameterized�template)�fix_switch_cases�fix_atomic_specifiersc@s�eZdZdedddddfdd�Z�d_dd	�Zd
d�Zdd
�Zdd�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd d!�Z�d`d"d#�Z�d`d$d%�Zd&d'�Zd(d)�Zd*Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Zd=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@dd��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�dDŽ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��Zd�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^S(a�CParserTzpycparser.lextabzpycparser.yacctabF�c
Cs~||j|j|j|jd�|_|jj|||d�|jj|_gd�}|D]}	|�|	�q!tj|d||||d�|_	t
�g|_d|_dS)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�	tabmodulerN)
�_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<�E/usr/local/CyberCP/lib/python3.10/site-packages/pycparser/c_parser.py�__init__s2:��
�

zCParser.__init__cCs6||j_|j��t�g|_d|_|jj||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)�inputr5r%)r+�filename�reset_linenor0r1r2r/�parse)r3�textr@r%r<r<r=rB�s

�z
CParser.parsecCs|j�t��dS�N)r1�appendr0�r3r<r<r=�_push_scope�szCParser._push_scopecCs t|j�dks	J�|j��dS)Nr)�lenr1�poprFr<r<r=�
_pop_scope�szCParser._pop_scopecCs4|jd�|d�s|�d||�d|jd|<dS)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��zCParser._add_typedef_namecCs4|jd�|d�r|�d||�d|jd|<dS)ze Add a new object, function, or enum member name (ie an ID) to the
            current scope
        rKFz;Non-typedef %r previously declared as typedef in this scopeNrLrOr<r<r=�_add_identifier�s��zCParser._add_identifiercCs.t|j�D]}|�|�}|dur|SqdS)z8 Is *name* a typedef-name in the current scope?
        NF)�reversedr1rM)r3rP�scope�in_scoper<r<r=�_is_type_in_scope�s
zCParser._is_type_in_scopecCs|�||�||��dSrD)rN�_coord)r3�msg�line�columnr<r<r=r'�szCParser._lex_error_funccC�|��dSrD)rGrFr<r<r=r(��zCParser._lex_on_lbrace_funccCr\rD)rJrFr<r<r=r)�r]zCParser._lex_on_rbrace_funccCs|�|�}|S)z� Looks up types that were previously defined with
            typedef.
            Passed to the lexer for recognizing identifiers that
            are types.
        )rW)r3rP�is_typer<r<r=r*�s
zCParser._lex_type_lookup_funccCs|jjS)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_tokenrFr<r<r=�_get_yacc_lookahead_token�sz!CParser._get_yacc_lookahead_tokencCsh|}|}|jr
|j}|jst|tj�r||_|S|}t|jtj�s+|j}t|jtj�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��zCParser._type_modify_declcCs�|}t|tj�s|j}t|tj�r|j|_|jdd�|_|D]}t|tj�s<t|�dkr5|�	d|j
�q||_|Sq|sYt|jtj�sM|�	d|j
�tjdg|j
d�|_|Stjdd�|D�|d	j
d�|_|S)
z- Fixes a declaration. Modifies decl.
        Nrz Invalid multiple types specifiedzMissing type in declaration�int�rQcSsg|]
}|jD]}|�qqSr<)�names)�.0�idrPr<r<r=�
<listcomp>Ssz/CParser._fix_decl_name_type.<locals>.<listcomp>�)rbrrcra�declnamerP�quals�IdentifierTyperHrNrQ�FuncDecl)r3rd�typenamera�tnr<r<r=�_fix_decl_name_type+s<�����
��zCParser._fix_decl_name_typecCs@|p
tgggggd�}|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)r0rE�insert)r3�declspec�newspec�kindrE�specr<r<r=�_add_declaration_specifierWs�z"CParser._add_declaration_specifiercCs\d|dv}g}|d�d�durn�|dddurtt|d�dks9t|dd	j�d
ks9|�|dd	jd�sRd}|dD]}t|d�rK|j}nq?|�d
|�tj|dd	jddd|d|dd	jd�|dd<|dd	=n:t	|ddtj
tjtjtj
f�s�|dd}t	|tj�s�|j}t	|tj�r�|jdur�|dd	jd|_|dd	=|D]{}	|	ddus�J�|r�tjd|d|d|	d|	djd�}
n!tjd|d|d|d|d|	d|	�d�|	�d�|	djd�	}
t	|
jtj
tjtjtj
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.
        �typedefryrp�bitsizeNrdra�rKr�?rQzInvalid declarationr{�rqrarr�alignrQrx)rPrrryrarQrz�init�	rPrrr�ry�funcspecrar�r�rQ)rMrHrlrW�hasattrrQrNrrcrb�Enum�Struct�Unionrsrarq�Typedef�DeclrwrRrPrSr
rE)r3r��decls�typedef_namespace�
is_typedef�declarationsrQ�t�decls_0_tailrd�declaration�
fixed_declr<r<r=�_build_declarationsps�&�
����

���zCParser._build_declarationscCsLd|dvr
|�d|j�|j|t|dd�gdd�d}tj||||jd	�S)
z' Builds a function definition.
        r�ryzInvalid typedefN�rdr�T�r�r�r�rp)rd�param_decls�bodyrQ)rNrQr�r0r�FuncDef)r3r�rdr�r�r�r<r<r=�_build_function_definition�s���z"CParser._build_function_definitioncCs|dkrtjStjS)z` Given a token (either STRUCT or UNION), selects the
            appropriate AST class.
        �struct)rr�r�)r3�tokenr<r<r=�_select_struct_union_class�sz"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�MODcCs4|ddurt�g�|d<dSt�|d�|d<dS)zh translation_unit_or_empty   : translation_unit
                                        | empty
        rNrp)r�FileAST�r3�pr<r<r=�p_translation_unit_or_empty�sz#CParser.p_translation_unit_or_emptycC�|d|d<dS)z4 translation_unit    : external_declaration
        rrpNr<r�r<r<r=�p_translation_unit_1�zCParser.p_translation_unit_1cCs"|d�|d�|d|d<dS)zE translation_unit    : translation_unit external_declaration
        rr�rpN)�extendr�r<r<r=�p_translation_unit_2szCParser.p_translation_unit_2cC�|dg|d<dS)z7 external_declaration    : function_definition
        rrpNr<r�r<r<r=�p_external_declaration_1�z CParser.p_external_declaration_1cCr�)z/ external_declaration    : declaration
        rrpNr<r�r<r<r=�p_external_declaration_2�z CParser.p_external_declaration_2cCr�)zi external_declaration    : pp_directive
                                    | pppragma_directive
        rrpNr<r�r<r<r=�p_external_declaration_3sz CParser.p_external_declaration_3cCsg|d<dS)z( external_declaration    : SEMI
        rpNr<r�r<r<r=�p_external_declaration_4%�z CParser.p_external_declaration_4cCr�)z1 external_declaration    : static_assert
        rrpNr<r�r<r<r=�p_external_declaration_5*r�z CParser.p_external_declaration_5cCsXt|�dkrt�|dd|�|d��g|d<dSt�|d|d|�|d��g|d<dS)z� static_assert           : _STATIC_ASSERT LPAREN constant_expression COMMA unified_string_literal RPAREN
                                    | _STATIC_ASSERT LPAREN constant_expression RPAREN
        ��Nrrp)rHr�StaticAssert�_token_coordr�r<r<r=�p_static_assert_declaration/s$(z#CParser.p_static_assert_declarationcCs|�d|�|d��dS)z  pp_directive  : PPHASH
        zDirectives not supported yetrN)rNr�r�r<r<r=�p_pp_directive8s
�zCParser.p_pp_directivecCstt|�dkrt�|d|�|d��|d<dSt|�dkr,t�|d|�|d��|d<dSt�d|�|d��|d<dS)z� pppragma_directive      : PPPRAGMA
                                    | PPPRAGMA PPPRAGMASTR
                                    | _PRAGMA LPAREN unified_string_literal RPAREN
        r�r�r�rprrN)rHr�Pragmar�r�r<r<r=�p_pppragma_directiveCs
  zCParser.p_pppragma_directivecC�0t|�dkr|dgn|d|dg|d<dS)z� pppragma_directive_list : pppragma_directive
                                    | pppragma_directive_list pppragma_directive
        r�rrpN�rHr�r<r<r=�p_pppragma_directive_listO�0z!CParser.p_pppragma_directive_listc
CsNtgggtjdg|�|d�d�ggd�}|j||d|d|dd�|d<d	S)
zU function_definition : id_declarator declaration_list_opt compound_statement
        rjrrk�rxr{ryrarzr�r��r�rdr�r�rpN)r0rrsr�r��r3r�r�r<r<r=�p_function_definition_1Ws
���zCParser.p_function_definition_1cCs.|d}|j||d|d|dd�|d<dS)zl function_definition : declaration_specifiers id_declarator declaration_list_opt compound_statement
        rr�r��r�rpN)r�r�r<r<r=�p_function_definition_2is�zCParser.p_function_definition_2cCr�)a_ statement   : labeled_statement
                        | expression_statement
                        | compound_statement
                        | selection_statement
                        | iteration_statement
                        | jump_statement
                        | pppragma_directive
                        | static_assert
        rrpNr<r�r<r<r=�p_statementxs
zCParser.p_statementcCsHt|�dkrtj|d|dg|�|d�d�|d<dS|d|d<dS)z} pragmacomp_or_statement     : pppragma_directive_list statement
                                        | statement
        r�rr���block_itemsrQrpN)rHr�Compoundr�r�r<r<r=�p_pragmacomp_or_statement�s
�z!CParser.p_pragmacomp_or_statementcCs�|d}|ddurN|d}tjtjtjf}t|�dkr@t|d|�r@tjd|d|d|d|d	|ddd|djd
�	g}n|j|t	ddd�gdd
�}n
|j||ddd
�}||d<dS)z� decl_body : declaration_specifiers init_declarator_list_opt
                      | declaration_specifiers_no_type id_init_declarator_list_opt
        rr�Nrarprxr{ryrzr�r�Tr�)
rr�r�r�rHrbr�rQr�r0)r3r�r��ty�s_u_or_er�r<r<r=�p_decl_body�s6
���zCParser.p_decl_bodycCr�)z& declaration : decl_body SEMI
        rrpNr<r�r<r<r=�
p_declarationr�zCParser.p_declarationcCs,t|�dkr
|dn|d|d|d<dS)zj declaration_list    : declaration
                                | declaration_list declaration
        r�rrpNr�r�r<r<r=�p_declaration_list	�,zCParser.p_declaration_listcC�|�|d|dd�|d<dS)z] declaration_specifiers_no_type  : type_qualifier declaration_specifiers_no_type_opt
        r�rrxrpN�r�r�r<r<r=�"p_declaration_specifiers_no_type_1�z*CParser.p_declaration_specifiers_no_type_1cCr�)zf declaration_specifiers_no_type  : storage_class_specifier declaration_specifiers_no_type_opt
        r�rryrpNr�r�r<r<r=�"p_declaration_specifiers_no_type_2r�z*CParser.p_declaration_specifiers_no_type_2cCr�)za declaration_specifiers_no_type  : function_specifier declaration_specifiers_no_type_opt
        r�rrzrpNr�r�r<r<r=�"p_declaration_specifiers_no_type_3r�z*CParser.p_declaration_specifiers_no_type_3cCr�)z_ declaration_specifiers_no_type  : atomic_specifier declaration_specifiers_no_type_opt
        r�rrarpNr�r�r<r<r=�"p_declaration_specifiers_no_type_4%r�z*CParser.p_declaration_specifiers_no_type_4cCr�)zb declaration_specifiers_no_type  : alignment_specifier declaration_specifiers_no_type_opt
        r�rr{rpNr�r�r<r<r=�"p_declaration_specifiers_no_type_5*r�z*CParser.p_declaration_specifiers_no_type_5cC�"|j|d|dddd�|d<dS)zI declaration_specifiers  : declaration_specifiers type_qualifier
        rr�rxT�rErpNr�r�r<r<r=�p_declaration_specifiers_1/�"z"CParser.p_declaration_specifiers_1cCr�)zR declaration_specifiers  : declaration_specifiers storage_class_specifier
        rr�ryTr�rpNr�r�r<r<r=�p_declaration_specifiers_24r�z"CParser.p_declaration_specifiers_2cCr�)zM declaration_specifiers  : declaration_specifiers function_specifier
        rr�rzTr�rpNr�r�r<r<r=�p_declaration_specifiers_39r�z"CParser.p_declaration_specifiers_3cCr�)zS declaration_specifiers  : declaration_specifiers type_specifier_no_typeid
        rr�raTr�rpNr�r�r<r<r=�p_declaration_specifiers_4>r�z"CParser.p_declaration_specifiers_4cC�|�d|dd�|d<dS)z2 declaration_specifiers  : type_specifier
        Nrrarpr�r�r<r<r=�p_declaration_specifiers_5C�z"CParser.p_declaration_specifiers_5cCr�)zQ declaration_specifiers  : declaration_specifiers_no_type type_specifier
        rr�raTr�rpNr�r�r<r<r=�p_declaration_specifiers_6Hr�z"CParser.p_declaration_specifiers_6cCr�)zN declaration_specifiers  : declaration_specifiers alignment_specifier
        rr�r{Tr�rpNr�r�r<r<r=�p_declaration_specifiers_7Mr�z"CParser.p_declaration_specifiers_7cCr�)a storage_class_specifier : AUTO
                                    | REGISTER
                                    | STATIC
                                    | EXTERN
                                    | TYPEDEF
                                    | _THREAD_LOCAL
        rrpNr<r�r<r<r=�p_storage_class_specifierR�z!CParser.p_storage_class_specifiercCr�)zR function_specifier  : INLINE
                                | _NORETURN
        rrpNr<r�r<r<r=�p_function_specifier\r�zCParser.p_function_specifiercC�$tj|dg|�|d�d�|d<dS)a+ type_specifier_no_typeid  : VOID
                                      | _BOOL
                                      | CHAR
                                      | SHORT
                                      | INT
                                      | LONG
                                      | FLOAT
                                      | DOUBLE
                                      | _COMPLEX
                                      | SIGNED
                                      | UNSIGNED
                                      | __INT128
        rrkrpN�rrsr�r�r<r<r=�p_type_specifier_no_typeidbs$z"CParser.p_type_specifier_no_typeidcCr�)z� type_specifier  : typedef_name
                            | enum_specifier
                            | struct_or_union_specifier
                            | type_specifier_no_typeid
                            | atomic_specifier
        rrpNr<r�r<r<r=�p_type_specifierrszCParser.p_type_specifiercCs |d}|j�d�||d<dS)z= atomic_specifier  : _ATOMIC LPAREN type_name RPAREN
        r��_AtomicrpN)rrrE)r3r��typr<r<r=�p_atomic_specifier|szCParser.p_atomic_specifiercCr�)z� type_qualifier  : CONST
                            | RESTRICT
                            | VOLATILE
                            | _ATOMIC
        rrpNr<r�r<r<r=�p_type_qualifier�szCParser.p_type_qualifiercC�0t|�dkr|d|dgn|dg|d<dS)z� init_declarator_list    : init_declarator
                                    | init_declarator_list COMMA init_declarator
        r�rr�rpNr�r�r<r<r=�p_init_declarator_list�r�zCParser.p_init_declarator_listcC�,t|dt|�dkr|dndd�|d<dS)zb init_declarator : declarator
                            | declarator EQUALS initializer
        rr�r�Nr�rp�r0rHr�r<r<r=�p_init_declarator�r�zCParser.p_init_declaratorcCr)z� id_init_declarator_list    : id_init_declarator
                                       | id_init_declarator_list COMMA init_declarator
        r�rr�rpNr�r�r<r<r=�p_id_init_declarator_list�r�z!CParser.p_id_init_declarator_listcCr)zn id_init_declarator : id_declarator
                               | id_declarator EQUALS initializer
        rr�r�Nr�rprr�r<r<r=�p_id_init_declarator�r�zCParser.p_id_init_declaratorcCr�)zY specifier_qualifier_list    : specifier_qualifier_list type_specifier_no_typeid
        rr�raTr�rpNr�r�r<r<r=�p_specifier_qualifier_list_1�r�z$CParser.p_specifier_qualifier_list_1cCr�)zO specifier_qualifier_list    : specifier_qualifier_list type_qualifier
        rr�rxTr�rpNr�r�r<r<r=�p_specifier_qualifier_list_2�r�z$CParser.p_specifier_qualifier_list_2cCr�)z4 specifier_qualifier_list  : type_specifier
        Nrrarpr�r�r<r<r=�p_specifier_qualifier_list_3�r�z$CParser.p_specifier_qualifier_list_3cCs$t|dgg|dggd�|d<dS)zH specifier_qualifier_list  : type_qualifier_list type_specifier
        rr�r�rpN�r0r�r<r<r=�p_specifier_qualifier_list_4�s$z$CParser.p_specifier_qualifier_list_4cCs tg|dggggd�|d<dS)z9 specifier_qualifier_list  : alignment_specifier
        rr�rpNrr�r<r<r=�p_specifier_qualifier_list_5�s z$CParser.p_specifier_qualifier_list_5cCr�)zR specifier_qualifier_list  : specifier_qualifier_list alignment_specifier
        rr�r{rpNr�r�r<r<r=�p_specifier_qualifier_list_6�r�z$CParser.p_specifier_qualifier_list_6cCs0|�|d�}||dd|�|d�d�|d<dS)z{ struct_or_union_specifier   : struct_or_union ID
                                        | struct_or_union TYPEID
        rr�N�rPr�rQrp)r�r��r3r��klassr<r<r=�p_struct_or_union_specifier_1�s
�z%CParser.p_struct_or_union_specifier_1cCsZ|�|d�}t|�dkr|dg|�|d�d�|d<dS|d|d|�|d�d�|d<dS)z� struct_or_union_specifier : struct_or_union brace_open struct_declaration_list brace_close
                                      | struct_or_union brace_open brace_close
        rr�Nr�rrpr��r�rHr�rr<r<r=�p_struct_or_union_specifier_2�s
�
�z%CParser.p_struct_or_union_specifier_2cCsb|�|d�}t|�dkr||dg|�|d�d�|d<dS||d|d|�|d�d�|d<dS)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
        rr�r�rrpr�Nrrr<r<r=�p_struct_or_union_specifier_3�s
�
�z%CParser.p_struct_or_union_specifier_3cCr�)zF struct_or_union : STRUCT
                            | UNION
        rrpNr<r�r<r<r=�p_struct_or_union�r�zCParser.p_struct_or_unioncCs<t|�dkr|dpg|d<dS|d|dpg|d<dS)z� struct_declaration_list     : struct_declaration
                                        | struct_declaration_list struct_declaration
        r�rrpNr�r�r<r<r=�p_struct_declaration_listsz!CParser.p_struct_declaration_listcCs�|d}d|dvsJ�|ddur|j||dd�}n4t|d�dkrD|dd}t|tj�r3|}nt�|�}|j|t|d	�gd�}n|j|tddd
�gd�}||d<dS)zW struct_declaration : specifier_qualifier_list struct_declarator_list_opt SEMI
        rr�ryr�N�r�r�rarp�rdr�)r�rHrbr�Nodersr0)r3r�r�r��node�	decl_typer<r<r=�p_struct_declaration_1
s*�

�	�zCParser.p_struct_declaration_1cC�d|d<dS)z# struct_declaration : SEMI
        Nrpr<r�r<r<r=�p_struct_declaration_20r�zCParser.p_struct_declaration_2cCr�)z1 struct_declaration : pppragma_directive
        rrpNr<r�r<r<r=�p_struct_declaration_35r�zCParser.p_struct_declaration_3cCr)z� struct_declarator_list  : struct_declarator
                                    | struct_declarator_list COMMA struct_declarator
        r�rr�rpNr�r�r<r<r=�p_struct_declarator_list:r�z CParser.p_struct_declarator_listcCs|ddd�|d<dS)z( struct_declarator : declarator
        rN�rdr�rpr<r�r<r<r=�p_struct_declarator_1CszCParser.p_struct_declarator_1cCsHt|�dkr|d|dd�|d<dSt�dddd�|dd�|d<dS)z� struct_declarator   : declarator COLON constant_expression
                                | COLON constant_expression
        r�rr%rpNr�)rHrrcr�r<r<r=�p_struct_declarator_2Hs"zCParser.p_struct_declarator_2cCs"t�|dd|�|d��|d<dS)zM enum_specifier  : ENUM ID
                            | ENUM TYPEID
        r�Nrrp�rr�r�r�r<r<r=�p_enum_specifier_1Qs"zCParser.p_enum_specifier_1cCs"t�d|d|�|d��|d<dS)zG enum_specifier  : ENUM brace_open enumerator_list brace_close
        Nr�rrpr(r�r<r<r=�p_enum_specifier_2Wr�zCParser.p_enum_specifier_2cC�&t�|d|d|�|d��|d<dS)z� enum_specifier  : ENUM ID brace_open enumerator_list brace_close
                            | ENUM TYPEID brace_open enumerator_list brace_close
        r�r�rrpNr(r�r<r<r=�p_enum_specifier_3\s&zCParser.p_enum_specifier_3cCslt|�dkrt�|dg|dj�|d<dSt|�dkr$|d|d<dS|dj�|d�|d|d<dS)z� enumerator_list : enumerator
                            | enumerator_list COMMA
                            | enumerator_list COMMA enumerator
        r�rrpr�N)rHr�EnumeratorListrQ�enumeratorsrEr�r<r<r=�p_enumerator_listbs zCParser.p_enumerator_listcC� t�|d|�|d��|d<dS)z� alignment_specifier  : _ALIGNAS LPAREN type_name RPAREN
                                 | _ALIGNAS LPAREN constant_expression RPAREN
        r�rrpN)r�Alignasr�r�r<r<r=�p_alignment_specifieros zCParser.p_alignment_specifiercCsbt|�dkrt�|dd|�|d��}nt�|d|d|�|d��}|�|j|j�||d<dS)zR enumerator  : ID
                        | ID EQUALS constant_expression
        r�rNr�rp)rHr�
Enumeratorr�rSrPrQ)r3r��
enumeratorr<r<r=�p_enumeratorus
�
�zCParser.p_enumeratorcCr�)zQ declarator  : id_declarator
                        | typeid_declarator
        rrpNr<r�r<r<r=�p_declarator�r�zCParser.p_declarator)rn�ID)�typeid�TYPEID)�typeid_noparenr9cCr�)z1 xxx_declarator  : direct_xxx_declarator
        rrpNr<r�r<r<r=�p_xxx_declarator_1�r�zCParser.p_xxx_declarator_1cC�|�|d|d�|d<dS)z9 xxx_declarator  : pointer direct_xxx_declarator
        r�rrpN�rir�r<r<r=�p_xxx_declarator_2��zCParser.p_xxx_declarator_2c	Cs(tj|dddd|�|d�d�|d<dS)z' direct_xxx_declarator   : yyy
        rNr�rp)rrcr�r�r<r<r=�p_direct_xxx_declarator_1�s
�z!CParser.p_direct_xxx_declarator_1cCr�)z@ direct_xxx_declarator   : LPAREN xxx_declarator RPAREN
        r�rpNr<r�r<r<r=�p_direct_xxx_declarator_2�r�z!CParser.p_direct_xxx_declarator_2cCsft|�dkr
|dngp
g}tjdt|�dkr|dn|d||djd�}|j|d|d�|d<dS)	z} direct_xxx_declarator   : direct_xxx_declarator LBRACKET type_qualifier_list_opt assignment_expression_opt RBRACKET
        r�r�Nr�r�ra�dim�	dim_qualsrQ�rdrerp)rHr�	ArrayDeclrQri)r3r�rr�arrr<r<r=�p_direct_xxx_declarator_3�s�z!CParser.p_direct_xxx_declarator_3cCs^dd�|d|dfD�}dd�|D�}tjd|d||djd	�}|j|d|d
�|d<dS)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
        cSs g|]}t|t�r|n|g�qSr<�rb�list)rm�itemr<r<r=ro�s�z5CParser.p_direct_xxx_declarator_4.<locals>.<listcomp>r�r�cSs"g|]
}|D]}|dur|�qqSrDr<)rm�sublistrxr<r<r=ro�s�Nr�rrBrErp�rrFrQri)r3r��listed_qualsrDrGr<r<r=�p_direct_xxx_declarator_4�s��z!CParser.p_direct_xxx_declarator_4c	CsZtjdt�|d|�|d��|ddur|dng|djd�}|j|d|d�|d<dS)zi direct_xxx_declarator   : direct_xxx_declarator LBRACKET type_qualifier_list_opt TIMES RBRACKET
        Nr�r�rrBrErp�rrFr7r�rQri�r3r�rGr<r<r=�p_direct_xxx_declarator_5�s�z!CParser.p_direct_xxx_declarator_5cCsztj|dd|djd�}|��jdkr0|jdur0|jjD]}t|tj�r'n	|�	|j
|j�q|j|d|d�|d<dS)z� direct_xxx_declarator   : direct_xxx_declarator LPAREN parameter_type_list RPAREN
                                    | direct_xxx_declarator LPAREN identifier_list_opt RPAREN
        r�Nr��argsrarQ�LBRACErErp)rrtrQr`rarT�paramsrb�
EllipsisParamrSrPri)r3r��func�paramr<r<r=�p_direct_xxx_declarator_6�s�
z!CParser.p_direct_xxx_declarator_6cCst|�|d�}tj|dp
gd|d�}t|�dkr4|d}|jdur)|j}|jdus!||_|d|d<dS||d<dS)zm pointer : TIMES type_qualifier_list_opt
                    | TIMES type_qualifier_list_opt pointer
        rr�N)rrrarQr�rp)r�r�PtrDeclrHra)r3r�rQ�nested_type�	tail_typer<r<r=�	p_pointer�s

�zCParser.p_pointercCr�)zs type_qualifier_list : type_qualifier
                                | type_qualifier_list type_qualifier
        r�rrpNr�r�r<r<r=�p_type_qualifier_listr�zCParser.p_type_qualifier_listcCs:t|�dkr|dj�t�|�|d���|d|d<dS)zn parameter_type_list : parameter_list
                                | parameter_list COMMA ELLIPSIS
        r�rr�rpN)rHrVrErrWr�r�r<r<r=�p_parameter_type_listszCParser.p_parameter_type_listcC�Pt|�dkrt�|dg|dj�|d<dS|dj�|d�|d|d<dS)zz parameter_list  : parameter_declaration
                            | parameter_list COMMA parameter_declaration
        r�rrpr�N�rHr�	ParamListrQrVrEr�r<r<r=�p_parameter_list#� zCParser.p_parameter_listcCsT|d}|dstjdg|�|d�d�g|d<|j|t|dd�gd�d|d<d	S)
z� parameter_declaration   : declaration_specifiers id_declarator
                                    | declaration_specifiers typeid_noparen_declarator
        rrarjrkr�rrrpN)rrsr�r�r0r�r<r<r=�p_parameter_declaration_17s
���z!CParser.p_parameter_declaration_1c
Cs�|d}|dstjdg|�|d�d�g|d<t|d�dkrGt|ddj�dkrG|�|ddjd�rG|j|t|ddd	�gd
�d}n$tjd|dd|dpYt�	dddd�|�|d�d
�}|d}|�
||�}||d<dS)zR parameter_declaration   : declaration_specifiers abstract_declarator_opt
        rrarjrkrKrpr�Nr�rrrx�rPrrr�rarQ)rrsr�rHrlrWr�r0�Typenamercrw)r3r�r�rdrur<r<r=�p_parameter_declaration_2Cs0
�&���
�z!CParser.p_parameter_declaration_2cCra)ze identifier_list : identifier
                            | identifier_list COMMA identifier
        r�rrpr�Nrbr�r<r<r=�p_identifier_listcrezCParser.p_identifier_listcCr�)z- initializer : assignment_expression
        rrpNr<r�r<r<r=�p_initializer_1mr�zCParser.p_initializer_1cCs8|ddurt�g|�|d��|d<dS|d|d<dS)z� initializer : brace_open initializer_list_opt brace_close
                        | brace_open initializer_list COMMA brace_close
        r�Nrrp)r�InitListr�r�r<r<r=�p_initializer_2rszCParser.p_initializer_2cCs�t|�dkr(|ddur|dn	t�|d|d�}t�|g|dj�|d<dS|ddur2|dn	t�|d|d�}|dj�|�|d|d<dS)z� initializer_list    : designation_opt initializer
                                | initializer_list COMMA designation_opt initializer
        r�rNr�rpr�)rHr�NamedInitializerrlrQ�exprsrE)r3r�r�r<r<r=�p_initializer_list{s((zCParser.p_initializer_listcCr�)z. designation : designator_list EQUALS
        rrpNr<r�r<r<r=�
p_designation�r�zCParser.p_designationcCr�)z_ designator_list : designator
                            | designator_list designator
        r�rrpNr�r�r<r<r=�p_designator_list�r�zCParser.p_designator_listcCr�)zi designator  : LBRACKET constant_expression RBRACKET
                        | PERIOD identifier
        r�rpNr<r�r<r<r=�p_designator�r�zCParser.p_designatorc
Cs\tjd|dddd�d|dpt�dddd�|�|d�d�}|�||dd�|d<dS)	zH type_name   : specifier_qualifier_list abstract_declarator_opt
        rrrxNr�rgrarp)rrhrcr�rw)r3r�rur<r<r=�p_type_name�s
�zCParser.p_type_namecCs*t�dddd�}|j||dd�|d<dS)z+ abstract_declarator     : pointer
        NrrErp)rrcri)r3r��	dummytyper<r<r=�p_abstract_declarator_1�s
�zCParser.p_abstract_declarator_1cCr<)zF abstract_declarator     : pointer direct_abstract_declarator
        r�rrpNr=r�r<r<r=�p_abstract_declarator_2�szCParser.p_abstract_declarator_2cCr�)z> abstract_declarator     : direct_abstract_declarator
        rrpNr<r�r<r<r=�p_abstract_declarator_3�r�zCParser.p_abstract_declarator_3cCr�)zA direct_abstract_declarator  : LPAREN abstract_declarator RPAREN r�rpNr<r�r<r<r=�p_direct_abstract_declarator_1��z&CParser.p_direct_abstract_declarator_1cCs6tjd|dg|djd�}|j|d|d�|d<dS)zn direct_abstract_declarator  : direct_abstract_declarator LBRACKET assignment_expression_opt RBRACKET
        Nr�rrBrErprMrQr<r<r=�p_direct_abstract_declarator_2�s�z&CParser.p_direct_abstract_declarator_2cCsbt|�dkr
|dngp
g}tjt�dddd�t|�dkr!|dn|d||�|d�d�|d<dS)zk direct_abstract_declarator  : LBRACKET type_qualifier_list_opt assignment_expression_opt RBRACKET
        r�r�Nr�rrBrp)rHrrFrcr�)r3r�rrr<r<r=�p_direct_abstract_declarator_3�s
�z&CParser.p_direct_abstract_declarator_3c	CsFtjdt�|d|�|d��g|djd�}|j|d|d�|d<dS)zZ direct_abstract_declarator  : direct_abstract_declarator LBRACKET TIMES RBRACKET
        Nr�rrBrErprPrQr<r<r=�p_direct_abstract_declarator_4�s�z&CParser.p_direct_abstract_declarator_4c	CsBtjt�dddd�t�|d|�|d��g|�|d�d�|d<dS)z? direct_abstract_declarator  : LBRACKET TIMES RBRACKET
        Nr�rrBrp)rrFrcr7r�r�r<r<r=�p_direct_abstract_declarator_5�s
�z&CParser.p_direct_abstract_declarator_5cCs4tj|dd|djd�}|j|d|d�|d<dS)zh direct_abstract_declarator  : direct_abstract_declarator LPAREN parameter_type_list_opt RPAREN
        r�NrrSrErp)rrtrQri)r3r�rXr<r<r=�p_direct_abstract_declarator_6�s�z&CParser.p_direct_abstract_declarator_6cCs0tj|dt�dddd�|�|d�d�|d<dS)zM direct_abstract_declarator  : LPAREN parameter_type_list_opt RPAREN
        r�NrrSrp)rrtrcr�r�r<r<r=�p_direct_abstract_declarator_7�s

�z&CParser.p_direct_abstract_declarator_7cCs(t|dt�r|dn|dg|d<dS)zG block_item  : declaration
                        | statement
        rrpNrIr�r<r<r=�p_block_item�(zCParser.p_block_itemcCs:t|�dks
|ddgkr|dn|d|d|d<dS)z_ block_item_list : block_item
                            | block_item_list block_item
        r�Nrrpr�r�r<r<r=�p_block_item_lists:zCParser.p_block_item_listcCs"tj|d|�|d�d�|d<dS)zA compound_statement : brace_open block_item_list_opt brace_close r�rr�rpN)rr�r�r�r<r<r=�p_compound_statement_1s
�zCParser.p_compound_statement_1cCs&t�|d|d|�|d��|d<dS)z6 labeled_statement : ID COLON pragmacomp_or_statement rr�rpN)r�Labelr�r�r<r<r=�p_labeled_statement_1�&zCParser.p_labeled_statement_1cCs(t�|d|dg|�|d��|d<dS)zL labeled_statement : CASE constant_expression COLON pragmacomp_or_statement r�r�rrpN)r�Caser�r�r<r<r=�p_labeled_statement_2�(zCParser.p_labeled_statement_2cCs"t�|dg|�|d��|d<dS)z; labeled_statement : DEFAULT COLON pragmacomp_or_statement r�rrpN)r�Defaultr�r�r<r<r=�p_labeled_statement_3s"zCParser.p_labeled_statement_3c	Cs(t�|d|dd|�|d��|d<dS)zK selection_statement : IF LPAREN expression RPAREN pragmacomp_or_statement r�r�Nrrp�r�Ifr�r�r<r<r=�p_selection_statement_1!r�zCParser.p_selection_statement_1c	Cs,t�|d|d|d|�|d��|d<dS)zZ selection_statement : IF LPAREN expression RPAREN statement ELSE pragmacomp_or_statement r�r��rrpNr�r�r<r<r=�p_selection_statement_2%s,zCParser.p_selection_statement_2c	Cs*tt�|d|d|�|d���|d<dS)zO selection_statement : SWITCH LPAREN expression RPAREN pragmacomp_or_statement r�r�rrpN)r	r�Switchr�r�r<r<r=�p_selection_statement_3)s�zCParser.p_selection_statement_3cCr+)zN iteration_statement : WHILE LPAREN expression RPAREN pragmacomp_or_statement r�r�rrpN)r�Whiler�r�r<r<r=�p_iteration_statement_1.r�zCParser.p_iteration_statement_1cCr+)zV iteration_statement : DO pragmacomp_or_statement WHILE LPAREN expression RPAREN SEMI r�r�rrpN)r�DoWhiler�r�r<r<r=�p_iteration_statement_22r�zCParser.p_iteration_statement_2c
Cs2t�|d|d|d|d|�|d��|d<dS)zx iteration_statement : FOR LPAREN expression_opt SEMI expression_opt SEMI expression_opt RPAREN pragmacomp_or_statement r�r�r��	rrpN)r�Forr�r�r<r<r=�p_iteration_statement_36s2zCParser.p_iteration_statement_3c
CsBt�t�|d|�|d��|d|d|d|�|d��|d<dS)zp iteration_statement : FOR LPAREN declaration expression_opt SEMI expression_opt RPAREN pragmacomp_or_statement r�rr���rpN)rr��DeclListr�r�r<r<r=�p_iteration_statement_4:s�zCParser.p_iteration_statement_4cCr0)z  jump_statement  : GOTO ID SEMI r�rrpN)r�Gotor�r�r<r<r=�p_jump_statement_1?� zCParser.p_jump_statement_1cC�t�|�|d��|d<dS)z jump_statement  : BREAK SEMI rrpN)r�Breakr�r�r<r<r=�p_jump_statement_2C�zCParser.p_jump_statement_2cCr�)z! jump_statement  : CONTINUE SEMI rrpN)r�Continuer�r�r<r<r=�p_jump_statement_3Gr�zCParser.p_jump_statement_3cCs0t�t|�dkr|dnd|�|d��|d<dS)z\ jump_statement  : RETURN expression SEMI
                            | RETURN SEMI
        r�r�Nrrp)r�ReturnrHr�r�r<r<r=�p_jump_statement_4Kr�zCParser.p_jump_statement_4cCs6|ddurt�|�|d��|d<dS|d|d<dS)z, expression_statement : expression_opt SEMI rNr�rp)r�EmptyStatementr�r�r<r<r=�p_expression_statementQszCParser.p_expression_statementcCslt|�dkr|d|d<dSt|dtj�s$t�|dg|dj�|d<|dj�|d�|d|d<dS)zn expression  : assignment_expression
                        | expression COMMA assignment_expression
        r�rrpr�N)rHrbr�ExprListrQrorEr�r<r<r=�p_expressionXszCParser.p_expressioncCr�)z: assignment_expression : LPAREN compound_statement RPAREN r�rpNr<r�r<r<r=�#p_parenthesized_compound_expressionerzz+CParser.p_parenthesized_compound_expressioncCr�)z typedef_name : TYPEID rrkrpNr�r�r<r<r=�p_typedef_namei�$zCParser.p_typedef_namecC�Ft|�dkr|d|d<dSt�|d|d|d|dj�|d<dS)z� assignment_expression   : conditional_expression
                                    | unary_expression assignment_operator assignment_expression
        r�rrpr�N)rHr�
AssignmentrQr�r<r<r=�p_assignment_expressionm�*zCParser.p_assignment_expressioncCr�)a� assignment_operator : EQUALS
                                | XOREQUAL
                                | TIMESEQUAL
                                | DIVEQUAL
                                | MODEQUAL
                                | PLUSEQUAL
                                | MINUSEQUAL
                                | LSHIFTEQUAL
                                | RSHIFTEQUAL
                                | ANDEQUAL
                                | OREQUAL
        rrpNr<r�r<r<r=�p_assignment_operator{s
zCParser.p_assignment_operatorcCr�)z. constant_expression : conditional_expression rrpNr<r�r<r<r=�p_constant_expression�rzzCParser.p_constant_expressioncCsFt|�dkr|d|d<dSt�|d|d|d|dj�|d<dS)z� conditional_expression  : binary_expression
                                    | binary_expression CONDOP expression COLON conditional_expression
        r�rrpr�r�N)rHr�	TernaryOprQr�r<r<r=�p_conditional_expression�r�z CParser.p_conditional_expressioncCr�)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�rrpr�N)rHr�BinaryOprQr�r<r<r=�p_binary_expression�s*zCParser.p_binary_expressioncCr�)z$ cast_expression : unary_expression rrpNr<r�r<r<r=�p_cast_expression_1�rzzCParser.p_cast_expression_1cCr+)z; cast_expression : LPAREN type_name RPAREN cast_expression r�r�rrpN)r�Castr�r�r<r<r=�p_cast_expression_2�r�zCParser.p_cast_expression_2cCr�)z* unary_expression    : postfix_expression rrpNr<r�r<r<r=�p_unary_expression_1�rzzCParser.p_unary_expression_1cCs$t�|d|d|dj�|d<dS)z� unary_expression    : PLUSPLUS unary_expression
                                | MINUSMINUS unary_expression
                                | unary_operator cast_expression
        rr�rpN�r�UnaryOprQr�r<r<r=�p_unary_expression_2�s$zCParser.p_unary_expression_2cCs:t�|dt|�dkr|dn|d|�|d��|d<dS)z� unary_expression    : SIZEOF unary_expression
                                | SIZEOF LPAREN type_name RPAREN
                                | _ALIGNOF LPAREN type_name RPAREN
        rr�r�rpN)rr�rHr�r�r<r<r=�p_unary_expression_3�s

�zCParser.p_unary_expression_3cCr�)z� unary_operator  : AND
                            | TIMES
                            | PLUS
                            | MINUS
                            | NOT
                            | LNOT
        rrpNr<r�r<r<r=�p_unary_operator�r�zCParser.p_unary_operatorcCr�)z* postfix_expression  : primary_expression rrpNr<r�r<r<r=�p_postfix_expression_1�rzzCParser.p_postfix_expression_1cCs$t�|d|d|dj�|d<dS)zG postfix_expression  : postfix_expression LBRACKET expression RBRACKET rr�rpN)r�ArrayRefrQr�r<r<r=�p_postfix_expression_2�r�zCParser.p_postfix_expression_2cCs4t�|dt|�dkr|dnd|dj�|d<dS)z� postfix_expression  : postfix_expression LPAREN argument_expression_list RPAREN
                                | postfix_expression LPAREN RPAREN
        rr�r�Nrp)r�FuncCallrHrQr�r<r<r=�p_postfix_expression_3�s4zCParser.p_postfix_expression_3cCs>t�|d|�|d��}t�|d|d||dj�|d<dS)z� postfix_expression  : postfix_expression PERIOD ID
                                | postfix_expression PERIOD TYPEID
                                | postfix_expression ARROW ID
                                | postfix_expression ARROW TYPEID
        r�rr�rpN)rr7r��	StructRefrQ)r3r��fieldr<r<r=�p_postfix_expression_4�s&zCParser.p_postfix_expression_4cCs(t�d|d|d|dj�|d<dS)z{ postfix_expression  : postfix_expression PLUSPLUS
                                | postfix_expression MINUSMINUS
        r�r�rrpNr�r�r<r<r=�p_postfix_expression_5�r�zCParser.p_postfix_expression_5cCst�|d|d�|d<dS)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�rpN)r�CompoundLiteralr�r<r<r=�p_postfix_expression_6�r?zCParser.p_postfix_expression_6cCr�)z" primary_expression  : identifier rrpNr<r�r<r<r=�p_primary_expression_1�rzzCParser.p_primary_expression_1cCr�)z  primary_expression  : constant rrpNr<r�r<r<r=�p_primary_expression_2�rzzCParser.p_primary_expression_2cCr�)zp primary_expression  : unified_string_literal
                                | unified_wstring_literal
        rrpNr<r�r<r<r=�p_primary_expression_3r�zCParser.p_primary_expression_3cCr�)z0 primary_expression  : LPAREN expression RPAREN r�rpNr<r�r<r<r=�p_primary_expression_4	rzzCParser.p_primary_expression_4cCsB|�|d�}t�t�|d|�t�|d|dg|�|�|d<dS)za primary_expression  : OFFSETOF LPAREN type_name COMMA offsetof_member_designator RPAREN
        rr�r�rpN)r�rr�r7r�)r3r�rQr<r<r=�p_primary_expression_5
s
�zCParser.p_primary_expression_5cCs�t|�dkr|d|d<dSt|�dkr)t�|d|d|d|dj�|d<dSt|�dkrAt�|d|d|dj�|d<dStdt|���)	z� offsetof_member_designator : identifier
                                         | offsetof_member_designator PERIOD identifier
                                         | offsetof_member_designator LBRACKET expression RBRACKET
        r�rrpr�r�r�z$Unexpected parsing state. len(p): %uN)rHrr�rQr��NotImplementedErrorr�r<r<r=�p_offsetof_member_designators*$z$CParser.p_offsetof_member_designatorcCra)z� argument_expression_list    : assignment_expression
                                        | argument_expression_list COMMA assignment_expression
        r�rrpr�N)rHrr�rQrorEr�r<r<r=�p_argument_expression_list#rez"CParser.p_argument_expression_listcCs t�|d|�|d��|d<dS)z identifier  : ID rrpN)rr7r�r�r<r<r=�p_identifier-r�zCParser.p_identifiercCs�d}d}|ddd�D]}|dvr|d7}q|dvr|d7}qd}|dkr*td��|d	kr2td
��d|d|}t�|d
|d|�|d��|d<dS)z� constant    : INT_CONST_DEC
                        | INT_CONST_OCT
                        | INT_CONST_HEX
                        | INT_CONST_BIN
                        | INT_CONST_CHAR
        rpr���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 zlong rj)�
ValueErrorr�Constantr�)r3r��uCount�lCount�xr��prefixr<r<r=�p_constant_11s"
��zCParser.p_constant_1cCshd|d��vrd}n|dddvrd}n
|dddvr!d}nd}t�||d|�|d��|d	<d
S)zM constant    : FLOAT_CONST
                        | HEX_FLOAT_CONST
        r�r�floatrK)�f�Fr�zlong double�doublerpN)�lowerrr�r�)r3r�r�r<r<r=�p_constant_2Hs�zCParser.p_constant_2cCs"t�d|d|�|d��|d<dS)z� constant    : CHAR_CONST
                        | WCHAR_CONST
                        | U8CHAR_CONST
                        | U16CHAR_CONST
                        | U32CHAR_CONST
        �charrrpN)rr�r�r�r<r<r=�p_constant_3Ys�zCParser.p_constant_3cCsft|�dkrt�d|d|�|d��|d<dS|djdd�|ddd�|d_|d|d<dS)z~ unified_string_literal  : STRING_LITERAL
                                    | unified_string_literal STRING_LITERAL
        r��stringrrpNrK)rHrr�r��valuer�r<r<r=�p_unified_string_literalhs�(z CParser.p_unified_string_literalcCsjt|�dkrt�d|d|�|d��|d<dS|dj��dd�|ddd�|d_|d|d<dS)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�rrpNrK)rHrr�r�r��rstripr�r<r<r=�p_unified_wstring_literalss
�,z!CParser.p_unified_wstring_literalcC�"|d|d<|�d|�d��dS)z  brace_open  :   LBRACE
        rrpN��
set_lineno�linenor�r<r<r=�p_brace_open��zCParser.p_brace_opencCr�)z  brace_close :   RBRACE
        rrpNr�r�r<r<r=�
p_brace_close�r�zCParser.p_brace_closecCr!)zempty : Nrpr<r�r<r<r=�p_empty�szCParser.p_emptycCsB|r|�d|j|j|j|j�|�d��dS|�d|jj�dS)Nz
before: %s)r�r[zAt end of input)rNr�rXr�r+�find_tok_columnr@r�r<r<r=�p_error�s
��zCParser.p_errorN)rF)F)��__name__�
__module__�__qualname__rr>rBrGrJrRrSrWr'r(r)r*r`rirwr�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�rrrrr	r
rrr
rrrrrrrrr r"r#r$r&r'r)r*r,r/r2r5r6rr;r>r@rArHrOrRrZr^r_r`rdrfrirjrkrmrprqrrrsrtrvrwrxryr{r|r}r~rr�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=rsv
�o	

	)2,Y	
	7=	

		&		
















	 
	

	

	

	
rN)�plyrrr�c_lexerr�	plyparserrrrr�ast_transformsr	r
rr<r<r<r=�<module>s