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


Python py010parser.parse_string函数代码示例

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


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


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