Home | History | Annotate | Download | only in lib2to3

Lines Matching refs:node

37         node = self
39 while node:
40 if node.type == TYPE_ALTERNATIVES:
41 node.alternatives.append(subp)
42 if len(node.alternatives) == len(node.children):
44 subp = [tuple(node.alternatives)]
45 node.alternatives = []
46 node = node.parent
49 node = node.parent
53 if node.type == TYPE_GROUP:
54 node.group.append(subp)
56 if len(node.group) == len(node.children):
57 subp = get_characteristic_subpattern(node.group)
58 node.group = []
59 node = node.parent
62 node = node.parent
66 if node.type == token_labels.NAME and node.name:
68 subp.append(node.name)
70 subp.append(node.type)
72 node = node.parent
104 def reduce_tree(node, parent=None):
113 #switch on the node type
114 if node.type == syms.Matcher:
116 node = node.children[0]
118 if node.type == syms.Alternatives :
120 if len(node.children) <= 2:
121 #just a single 'Alternative', skip this node
122 new_node = reduce_tree(node.children[0], parent)
127 for child in node.children:
128 if node.children.index(child)%2:
133 elif node.type == syms.Alternative:
134 if len(node.children) > 1:
137 for child in node.children:
146 new_node = reduce_tree(node.children[0], parent)
148 elif node.type == syms.Unit:
149 if (isinstance(node.children[0], pytree.Leaf) and
150 node.children[0].value == '('):
152 return reduce_tree(node.children[1], parent)
153 if ((isinstance(node.children[0], pytree.Leaf) and
154 node.children[0].value == '[')
156 (len(node.children)>1 and
157 hasattr(node.children[1], "value") and
158 node.children[1].value == '[')):
169 for child in node.children:
184 name_leaf = node.children[2]
187 name_leaf = node.children[3]
189 name_leaf = node.children[0]
191 #set node type