def addASTChild(self, currentAST, child): if not child: return rootnode = Node(None, sys._getframe(1).f_code.co_name, source_line=self.LT(1).getLine(), source_file=self.getFilename()) if child.node: if not currentAST.root: rootnode.children = [child.node] else: rootnode = child.node # Node(sys._getframe(1).f_code.co_name, children=[child.node]) child.node = rootnode child.node.leaf = child.getText() if child.node is None: print child if not currentAST.root: currentAST.root = child elif not currentAST.child: currentAST.root.setFirstChild(child) else: currentAST.root.node.add_child(child.node) currentAST.child.setNextSibling(child) currentAST.child = child currentAST.advanceChildToEnd()
def addASTChild(self,currentAST, child): if not child: return rootnode = Node(None,sys._getframe(1).f_code.co_name, source_line = self.LT(1).getLine(), source_file = self.getFilename()) if child.node: if not currentAST.root: rootnode.children = [child.node] else: rootnode = child.node # Node(sys._getframe(1).f_code.co_name, children=[child.node]) child.node = rootnode child.node.leaf = child.getText() if child.node is None: print child if not currentAST.root: currentAST.root = child elif not currentAST.child: currentAST.root.setFirstChild(child) else: currentAST.root.node.add_child(child.node) currentAST.child.setNextSibling(child) currentAST.child = child currentAST.advanceChildToEnd()