本文整理汇总了Python中magpieparsers.parser_common.Node.del_attributes方法的典型用法代码示例。如果您正苦于以下问题:Python Node.del_attributes方法的具体用法?Python Node.del_attributes怎么用?Python Node.del_attributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类magpieparsers.parser_common.Node
的用法示例。
在下文中一共展示了Node.del_attributes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: interf
# 需要导入模块: from magpieparsers.parser_common import Node [as 别名]
# 或者: from magpieparsers.parser_common.Node import del_attributes [as 别名]
def interf(self,ast, pt, decorators):
# ... create the type
interface = Node(ast, 'type', source = pt)
interface.add_attribute('meta_type', 'interface')
# ... add modifiers
if pt.leaf == 'abstract' or pt.leaf == 'local':
interface.add_attribute('modifier', pt.leaf)
# ... set interface name
interface.leaf = pt.the('identifier').leaf
# If the interface already exists in incomplete form, use that instead.
old_interfaces = infogripper.getAllNodes(interface.leaf, ast, 'type')
if old_interfaces:
# Found a previous declaration; use that.
assert len(old_interfaces) == 1
interface = old_interfaces[0]
else:
# Okay, it doesn't exist already: add it.
ast.add_child(interface)
# While we're building it, add the "incomplete" attribute.
interface.add_attribute('incomplete', True)
is_incomplete = True
for child in pt.children:
if child.type == 'interface_dcl':
is_incomplete = False
#print child
if child.the('interface_header') != None:
scope_list = child.the('interface_header').the('interface_inheritance_spec').the('scoped_name_list')
for scope_name in scope_list['scoped_name']:
inher_node = Node(interface, 'inherits', leaf = self.scoped_name(scope_name), source = child)
inher_node.add_child(infogripper.find_scope(interface, inher_node.leaf))
# Ensure we're not inheriting from the same class twice.
self.check_not_inherited(interface, inher_node.children[0], error_infonode = scope_name)
interface.add_child(inher_node)
if child.the('interface_body') != None:
for export_child in child.the('interface_body').children:
self.export(interface, export_child)
# Remove "incomplete" if the interface was fully-defined above.
if not is_incomplete:
interface.del_attributes('incomplete')
interface.add_children(decorators)
self._dupes_check(interface)