• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python py010parser.parse_string函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中py010parser.parse_string函数的典型用法代码示例。如果您正苦于以下问题:Python parse_string函数的具体用法?Python parse_string怎么用?Python parse_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: _parse_string

	def _parse_string(self, string, predefines=True):
		exts = []
		if predefines:
			for predefine in self._predefines:
				try:
					ast = py010parser.parse_string(predefine, parser=self._parser, cpp_path=self._cpp_path, cpp_args=self._cpp_args)
					exts += ast.ext
				except:
					pass

		res = py010parser.parse_string(string, parser=self._parser, cpp_path=self._cpp_path, cpp_args=self._cpp_args)
		res.ext = exts + res.ext

		return res
开发者ID:slox3r,项目名称:pfp,代码行数:14,代码来源:interp.py


示例2: test_untypedefd_enum_as_typeid

 def test_untypedefd_enum_as_typeid(self):
     res = parse_string("""
         enum <ulong> BLAH {
             BLAH1, BLAH2, BLAH3
         };
         local BLAH x;
     """, optimize=True)
开发者ID:melbcat,项目名称:py010parser,代码行数:7,代码来源:test_basic_parse.py


示例3: test_basic

 def test_basic(self):
     res = parse_string("""
         struct NAME {
                 int		stringLength;
                 char	name[stringLength];
         } name;
     """, optimize=True)
开发者ID:melbcat,项目名称:py010parser,代码行数:7,代码来源:test_basic_parse.py


示例4: test_value_types

    def test_value_types(self):
        res = parse_string("""
            time_t var1;
            OLETIME var2;
            FILETIME var3;
            DOSTIME var4;
            DOSDATE var5;
            HFLOAT var6;
            hfloat var7;
            DOUBLE var8;
            double var9;
            FLOAT var10;
            float var11;
            __uint64 var12;
            QWORD var13;
            UINT64 var14;
            UQUAD var15;
            uquad var16;
            uint64 var17;
            __int64 var18;
            INT64 var19;
            QUAD var20;
            quad var21;
            int64 var22;
            DWORD var23;
            ULONG var24;
            UINT32 var25;
            UINT var26;
            ulong var27;
            uint32 var28;
            uint var29;
            LONG var30;
            INT32 var31;
            INT var32;
            long var33;
            int32 var34;
            int var35;
            WORD var36;
            UINT16 var37;
            USHORT var38;
            uint16 var39;
            ushort var40;
            INT16 var41;
            SHORT var42;
            int16 var43;
            short var44;
            UBYTE var45;
            UCHAR var46;
            ubyte var47;
            uchar var48;
            BYTE var49;
            CHAR var50;
            byte var51;
            char var52;

            string var53;
            wstring var54;
            wchar_t var55;
        """, optimize=True)
开发者ID:melbcat,项目名称:py010parser,代码行数:59,代码来源:test_basic_parse.py


示例5: test_pass_by_reference

    def test_pass_by_reference(self):
        res = parse_string("""
        void some_function(int &num, int &num2) {
        }

        void some_function(int &num2) {
        }
        """, optimize=True)
开发者ID:melbcat,项目名称:py010parser,代码行数:8,代码来源:test_basic_parse.py


示例6: test_declaration_in_if

 def test_declaration_in_if(self):
     res = parse_string("""
         if(1) {
             int c;
         } else {
             int b;
         }
     """, optimize=True)
开发者ID:melbcat,项目名称:py010parser,代码行数:8,代码来源:test_basic_parse.py


示例7: test_struct_bitfield_with_metadata

 def test_struct_bitfield_with_metadata(self):
     res = parse_string("""
         typedef struct tgCifDirEntry {
                 uint16 storage_method : 2;
                 uint16 data_type : 3;
                 uint16 id_code : 11 <format=hex>;
         } CifDirEntry <read=ReadCifDirEntry>;
     """, optimize=True)
开发者ID:melbcat,项目名称:py010parser,代码行数:8,代码来源:test_basic_parse.py


示例8: test_initializer_in_struct

 def test_initializer_in_struct(self):
     res = parse_string("""
         local int b = 11;
         typedef struct BLAH {
             local int a = 10;
             int a:10;
         } blah;
     """, optimize=True)
开发者ID:melbcat,项目名称:py010parser,代码行数:8,代码来源:test_basic_parse.py


示例9: test_declaration_in_struct

 def test_declaration_in_struct(self):
     res = parse_string("""
         int c;
         switch(c) {
             case 1:
                 c++;
             case 2:
                 int c;
         }
     """, optimize=True)
开发者ID:melbcat,项目名称:py010parser,代码行数:10,代码来源:test_basic_parse.py


示例10: test_block_item_at_root

    def test_block_item_at_root(self):
        # had to get rid of the default int ret val on functions
        # from pycparser

        res = parse_string("""
        int a = 10;
        void some_function(int num) {
            some_function();
        }
        a++;
        some_function();
        """, optimize=True)
开发者ID:melbcat,项目名称:py010parser,代码行数:12,代码来源:test_basic_parse.py


示例11: test_struct_with_args_calling_not_func_decl2

    def test_struct_with_args_calling_not_func_decl2(self):
        res = parse_string("""
            typedef struct(int a) {
                char chars[a];
            } test_structure;

            local int size = 4;
            test_structure test(size); // this SHOULD NOT be a function declaration
        """, predefine_types=False)
        decl = res.children()[2][1]
        self.assertEqual(decl.type.__class__, c_ast.StructCallTypeDecl)
        self.assertEqual(decl.type.args.__class__, c_ast.ExprList)
开发者ID:strazzere,项目名称:py010parser,代码行数:12,代码来源:test_basic_parse.py


示例12: test_bitfield_in_if

    def test_bitfield_in_if(self):
        res = parse_string("""
            struct {
                if(1) {
                    int field1:16;
                    //int field1;
                }
            } blah;
        """, optimize=True, predefine_types=False)

        bitfield_decl = res.children()[0][1].type.type.children()[0][1].iftrue.children()[0][1]
        self.assertNotEqual(type(bitfield_decl), dict)
开发者ID:strazzere,项目名称:py010parser,代码行数:12,代码来源:test_basic_parse.py


示例13: test_c_keywords_in_enum

 def test_c_keywords_in_enum(self):
     res = parse_string("""
         enum <int> BLAH {
             goto,
             register,
             extern,
             goto,
             volatile,
             static
         };
         local BLAH x;
     """, optimize=True)
开发者ID:d0c-s4vage,项目名称:py010parser,代码行数:12,代码来源:test_enum.py


示例14: test_nested_bitfield_in_struct

 def test_nested_bitfield_in_struct(self):
     res = parse_string("""
         typedef struct BLAH {
             int a;
             switch(a) {
                 case 10:
                     int b:10;
                 default:
                     int c:10;
             }
         } blah;
     """, optimize=True)
开发者ID:melbcat,项目名称:py010parser,代码行数:12,代码来源:test_basic_parse.py


示例15: test_comment_single_line

    def test_comment_single_line(self):
        res = parse_string("""
            // this is a comment
            int blah;
        """, optimize=True, predefine_types=False)

        self.assertEqual(len(res.children()), 1, "should only have one node in the AST")

        node = res.children()[0][1]
        self.assertEqual(node.name, "blah")
        self.assertEqual(node.type.declname, "blah")
        self.assertEqual(node.type.type.names, ["int"])
开发者ID:d0c-s4vage,项目名称:py010parser,代码行数:12,代码来源:test_basic_parse.py


示例16: test_if_in_struct

    def test_if_in_struct(self):
        res = parse_string("""
            struct BLAH {
                int a:1;
                int b:2;
                int c:29;

                if(hello) {
                    b = 10;
                }
            } blah;
            """, optimize=True)
开发者ID:melbcat,项目名称:py010parser,代码行数:12,代码来源:test_basic_parse.py


示例17: test_structs_with_params_resetting1

    def test_structs_with_params_resetting1(self):
        res = parse_string("""
            typedef struct (int a, int b) {
                char chars1[a];
                char chars2[b];
            } blah;

            blah test(2, 3);
        """, optimize=True)

        res = parse_string("""
            typedef union {
                int some_int;
                struct {
                    char a;
                    char b;
                    char c;
                    char d;
                } some_chars;
            } blah;

            blah some_union;
        """, optimize=True)
开发者ID:d0c-s4vage,项目名称:py010parser,代码行数:23,代码来源:test_struct.py


示例18: test_basic_struct_typedef

    def test_basic_struct_typedef(self):
        res = parse_string("""
            typedef union {
                int some_int;
                struct {
                    char a;
                    char b;
                    char c;
                    char d;
                } some_chars;
            } blah;

            blah some_union;
        """, optimize=True, predefine_types=False)
开发者ID:d0c-s4vage,项目名称:py010parser,代码行数:14,代码来源:test_struct.py


示例19: test_switch_in_struct

    def test_switch_in_struct(self):
        res = parse_string("""
            struct BLAH {
                int c;

                switch(c) {
                    case 1:
                        int aa;
                    case 2:
                        int bb;
                    default:
                        int cc;
                }
            } blah;
            """, optimize=True)
开发者ID:melbcat,项目名称:py010parser,代码行数:15,代码来源:test_basic_parse.py


示例20: test_basic_struct_with_args_calling

    def test_basic_struct_with_args_calling(self):
        res = parse_string("""
            typedef struct (int a) {
                int blah;
            } SPECIAL_STRUCT;

            SPECIAL_STRUCT test(10);

            int blah() {
                return 10;
            }
        """, optimize=True, predefine_types=False)
        decl = res.children()[1][1]
        self.assertTrue(isinstance(decl.type, c_ast.StructCallTypeDecl))
        decl_args = decl.type.args.children()
        self.assertEqual(decl_args[0][1].value, "10")
        self.assertEqual(len(decl_args), 1)
开发者ID:strazzere,项目名称:py010parser,代码行数:17,代码来源:test_basic_parse.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python py2exe.run函数代码示例发布时间:2022-05-25
下一篇:
Python html.tr函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap