Пример #1
0
 /**
  * Duplicate a tree, assuming this is a root node of a tree-- duplicate that node and what's
  * below; ignore siblings of root node.
  */
 public static GrammarAST dupTreeNoActions(GrammarAST t, GrammarAST parent) {
   if (t == null) {
     return null;
   }
   GrammarAST result = (GrammarAST) t.dupNode();
   for (GrammarAST subchild : getChildrenForDupTree(t)) {
     result.addChild(dupTreeNoActions(subchild, result));
   }
   return result;
 }
Пример #2
0
 public static GrammarAST dupTree(GrammarAST t) {
   if (t == null) {
     return null;
   }
   GrammarAST root = dup(t); // make copy of root
   // copy all children of root.
   for (int i = 0; i < t.getChildCount(); i++) {
     GrammarAST child = (GrammarAST) t.getChild(i);
     root.addChild(dupTree(child));
   }
   return root;
 }