当前位置: 首页>>代码示例>>Python>>正文


Python GnuCParser.parse方法代码示例

本文整理汇总了Python中pycparserext.ext_c_parser.GnuCParser.parse方法的典型用法代码示例。如果您正苦于以下问题:Python GnuCParser.parse方法的具体用法?Python GnuCParser.parse怎么用?Python GnuCParser.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pycparserext.ext_c_parser.GnuCParser的用法示例。


在下文中一共展示了GnuCParser.parse方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_array_ptr_decl_attribute

# 需要导入模块: from pycparserext.ext_c_parser import GnuCParser [as 别名]
# 或者: from pycparserext.ext_c_parser.GnuCParser import parse [as 别名]
def test_array_ptr_decl_attribute():
    src = """
    int* __attribute__((weak)) array[256];
    """

    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)
    ast.show()
开发者ID:h4ck3rm1k3,项目名称:pycparserext,代码行数:11,代码来源:test_pycparserext.py

示例2: test_gnu_statement_expression

# 需要导入模块: from pycparserext.ext_c_parser import GnuCParser [as 别名]
# 或者: from pycparserext.ext_c_parser.GnuCParser import parse [as 别名]
def test_gnu_statement_expression():
    src = """
      int func(int a) {
        return (int)({; ; *(int*)&a;});
     }
    """
    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)
    ast.show()
开发者ID:h4ck3rm1k3,项目名称:pycparserext,代码行数:12,代码来源:test_pycparserext.py

示例3: test_funky_header_code_5

# 需要导入模块: from pycparserext.ext_c_parser import GnuCParser [as 别名]
# 或者: from pycparserext.ext_c_parser.GnuCParser import parse [as 别名]
def test_funky_header_code_5():
    src=""" void  do_foo(void) __asm(__STRING(do_foo));"""

    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)
    ast.show()

    from pycparserext.ext_c_generator import GnuCGenerator
    print(GnuCGenerator().visit(ast))
开发者ID:h4ck3rm1k3,项目名称:pycparserext,代码行数:12,代码来源:test_pycparserext.py

示例4: test_func_ret_ptr_decl_attribute

# 需要导入模块: from pycparserext.ext_c_parser import GnuCParser [as 别名]
# 或者: from pycparserext.ext_c_parser.GnuCParser import parse [as 别名]
def test_func_ret_ptr_decl_attribute():
    src = """
    extern void* memcpy(const void* src, const void *dst, int len) __attribute__((unused));
    """
    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)
    ast.show()

    from pycparserext.ext_c_generator import GnuCGenerator
    print(GnuCGenerator().visit(ast))
开发者ID:h4ck3rm1k3,项目名称:pycparserext,代码行数:13,代码来源:test_pycparserext.py

示例5: test_asm_volatile_2

# 需要导入模块: from pycparserext.ext_c_parser import GnuCParser [as 别名]
# 或者: from pycparserext.ext_c_parser.GnuCParser import parse [as 别名]
def test_asm_volatile_2():
    src = """
    void read_tsc(void) {
        long val;
        asm volatile("rdtsc" : "=A" (val));
    }    """
    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)
    ast.show()

    from pycparserext.ext_c_generator import GnuCGenerator
    print GnuCGenerator().visit(ast)
开发者ID:pombredanne,项目名称:pycparserext,代码行数:15,代码来源:test_pycparserext.py

示例6: test_empty_struct_declaration

# 需要导入模块: from pycparserext.ext_c_parser import GnuCParser [as 别名]
# 或者: from pycparserext.ext_c_parser.GnuCParser import parse [as 别名]
def test_empty_struct_declaration():
    src = """
        typedef struct Foo {
        } Foo_t;
    """

    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)
    ast.show()

    from pycparserext.ext_c_generator import GnuCGenerator
    print(GnuCGenerator().visit(ast))
开发者ID:h4ck3rm1k3,项目名称:pycparserext,代码行数:15,代码来源:test_pycparserext.py

示例7: test_array_attributes

# 需要导入模块: from pycparserext.ext_c_parser import GnuCParser [as 别名]
# 或者: from pycparserext.ext_c_parser.GnuCParser import parse [as 别名]
def test_array_attributes():
    src = """
        int x[10] __attribute__((unused));
        int y[20] __attribute((aligned(10)));
        """

    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)
    ast.show()

    from pycparserext.ext_c_generator import GnuCGenerator
    print(GnuCGenerator().visit(ast))
开发者ID:h4ck3rm1k3,项目名称:pycparserext,代码行数:15,代码来源:test_pycparserext.py

示例8: test_asm_volatile_3

# 需要导入模块: from pycparserext.ext_c_parser import GnuCParser [as 别名]
# 或者: from pycparserext.ext_c_parser.GnuCParser import parse [as 别名]
def test_asm_volatile_3():
    src = """
    void read_tsc(void) {
        long fpenv;
        asm("mtfsf 255,%0" :: "f" (fpenv));
    }    """
    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)
    ast.show()

    from pycparserext.ext_c_generator import GnuCGenerator
    print GnuCGenerator().visit(ast)
开发者ID:pombredanne,项目名称:pycparserext,代码行数:15,代码来源:test_pycparserext.py

示例9: test_lvalue_gnu_statement_expression

# 需要导入模块: from pycparserext.ext_c_parser import GnuCParser [as 别名]
# 或者: from pycparserext.ext_c_parser.GnuCParser import parse [as 别名]
def test_lvalue_gnu_statement_expression():
    src = """
      int func(int a) {
        int ret=(int)({; ; *(int*)&a;});
        return ret;
     }
    """

    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)
    ast.show()

    from pycparserext.ext_c_generator import GnuCGenerator
    print(GnuCGenerator().visit(ast))
开发者ID:h4ck3rm1k3,项目名称:pycparserext,代码行数:17,代码来源:test_pycparserext.py

示例10: test_func_decl_attribute

# 需要导入模块: from pycparserext.ext_c_parser import GnuCParser [as 别名]
# 或者: from pycparserext.ext_c_parser.GnuCParser import parse [as 别名]
def test_func_decl_attribute():
    src = """
    extern void int happy(void) __attribute__((unused));
    int main()
    {
    }
    """

    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)
    ast.show()

    from pycparserext.ext_c_generator import GnuCGenerator
    print(GnuCGenerator().visit(ast))
开发者ID:h4ck3rm1k3,项目名称:pycparserext,代码行数:17,代码来源:test_pycparserext.py

示例11: test_funky_header_code

# 需要导入模块: from pycparserext.ext_c_parser import GnuCParser [as 别名]
# 或者: from pycparserext.ext_c_parser.GnuCParser import parse [as 别名]
def test_funky_header_code():
    src = """
        extern __inline int __attribute__ ((__nothrow__)) __signbitf (float __x)
         {
           int __m;
           __asm ("pmovmskb %1, %0" : "=r" (__m) : "x" (__x));
           return __m & 0x8;
         }
        """

    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)

    from pycparserext.ext_c_generator import GnuCGenerator
    print GnuCGenerator().visit(ast)
开发者ID:nrfulton,项目名称:pycparserext,代码行数:18,代码来源:test_pycparserext.py

示例12: test_empty_gnu_statement_expression

# 需要导入模块: from pycparserext.ext_c_parser import GnuCParser [as 别名]
# 或者: from pycparserext.ext_c_parser.GnuCParser import parse [as 别名]
def test_empty_gnu_statement_expression():
    # Incase, ASSERTS turn out to be empty statements
    src = """
      int func(int a) {
              ({
                    ; ;
                         });
                }
    """

    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)
    ast.show()

    from pycparserext.ext_c_generator import GnuCGenerator
    print(GnuCGenerator().visit(ast))
开发者ID:h4ck3rm1k3,项目名称:pycparserext,代码行数:19,代码来源:test_pycparserext.py

示例13: GnuCParser

# 需要导入模块: from pycparserext.ext_c_parser import GnuCParser [as 别名]
# 或者: from pycparserext.ext_c_parser.GnuCParser import parse [as 别名]
from pycparserext.ext_c_parser import GnuCParser
p = GnuCParser()
src="""
typedef int wchar_t;
extern wchar_t *wcscpy (wchar_t *restrict __dest,
const wchar_t *__restrict __src) __attribute ((nothrow , leaf));

"""
p.parse(src).show()
开发者ID:h4ck3rm1k3,项目名称:pycparserext,代码行数:11,代码来源:test.py

示例14: visit_AttributeSpecifier

# 需要导入模块: from pycparserext.ext_c_parser import GnuCParser [as 别名]
# 或者: from pycparserext.ext_c_parser.GnuCParser import parse [as 别名]
    def visit_AttributeSpecifier(self, n):
        return ' __attribute__((' + self.visit(n.exprlist) + '))'

####################################################################################################

class MyCGenerator(AsmAndAttributesMixin, CGenerator):
    pass

####################################################################################################

file_path = 'fitz-from-cpp.h'
with open(file_path, 'r') as f:
    source = f.read()

parser = GnuCParser()
ast = parser.parse(source)

# ast.show()

# generator = FunctionDeclarationGenerator()
generator = MyCGenerator()
source = generator.visit(ast)
# print(source)

print('\nStructs:')
for name in generator.structs:
    if name and name.startswith('fz_'):
        print(name)

print('\nFunctions:')
for name in generator.functions:
开发者ID:FabriceSalvaire,项目名称:Biblio,代码行数:33,代码来源:test-pycparserext.py


注:本文中的pycparserext.ext_c_parser.GnuCParser.parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。