本文整理汇总了Python中magpieparsers.parser_common.Node.type方法的典型用法代码示例。如果您正苦于以下问题:Python Node.type方法的具体用法?Python Node.type怎么用?Python Node.type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类magpieparsers.parser_common.Node
的用法示例。
在下文中一共展示了Node.type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: import_dcl
# 需要导入模块: from magpieparsers.parser_common import Node [as 别名]
# 或者: from magpieparsers.parser_common.Node import type [as 别名]
def import_dcl(self, pt):
ast = Node(None, None, source = pt)
ast.type = "cimport" #pt.leaf
"""
if pt.leaf == 'import':
#imported_scope
child = pt.the('imported_scope').children[0]
elif pt.leaf == 'cimport':
child = pt.the('anglequoted_scope').children[0]
"""
child = pt.children[0].children[0]
assert child is not None
if child.type == 'string_literal':
ast.leaf = child.leaf
elif child.type == 'scoped_name':
ast.leaf = self.scoped_name(child)
elif child.type == 'anglequoted_string_literal':
ast.leaf = child.leaf
else:
ast = Node(None, child, source = pt)
ast.type = 'import'
return ast
示例2: member_list
# 需要导入模块: from magpieparsers.parser_common import Node [as 别名]
# 或者: from magpieparsers.parser_common.Node import type [as 别名]
def member_list(self, ast, pt):
members = Node(ast, None, source = pt)
members.type = 'members'
for child in pt.children:
if child.type == 'member':
typeref, new_type = self.type_spec(members, child.the('type_spec'))
if new_type:
if isinstance(typeref, str):
pass
else:
members.add_child(typeref)
members.add_children(self.create_instance_list(members, typeref, child.the('declarators').children))
else:
print 'memberlist_unknown' + child.type
return [members]