Пример #1
0
 def p_direct_abstract_declarator_3(self, p):
     """ direct_abstract_declarator  : LBRACKET constant_expression_opt RBRACKET
     """
     p[0] = c_ast.ArrayDecl(
         type=c_ast.TypeDecl(None, None, None),
         dim=p[2],
         coord=self._coord(p.lineno(1)))
Пример #2
0
    def p_direct_declarator_3(self, p):
        """ direct_declarator   : direct_declarator LBRACKET type_qualifier_list_opt assignment_expression_opt RBRACKET """
        arr = c_ast.ArrayDecl(
            type=None,
            dim=p[4],
            dim_quals=p[3] or [],
            coord=p[1].coord)

        p[0] = self._type_modify_decl(decl=p[1], modifier=arr)
Пример #3
0
    def p_direct_abstract_declarator_2(self, p):
        """ direct_abstract_declarator  : direct_abstract_declarator LBRACKET constant_expression_opt RBRACKET
        """
        arr = c_ast.ArrayDecl(
            type=None,
            dim=p[3],
            coord=p[1].coord)

        p[0] = self._type_modify_decl(decl=p[1], modifier=arr)
Пример #4
0
    def p_direct_declarator_4(self, p):
        """ direct_declarator   : direct_declarator LBRACKET STATIC type_qualifier_list assignment_expression RBRACKET
                                | direct_declarator LBRACKET type_qualifier_list STATIC assignment_expression RBRACKET
        """
        dim_quals = p[3] + [p[4]] if isinstance(p[3], list) else p[4] + [p[3]]
        arr = c_ast.ArrayDecl(
            type=None,
            dim=p[5],
            dim_quals=dim_quals,
            coord=p[1].coord)

        p[0] = self._type_modify_decl(decl=p[1], modifier=arr)