/** Treat next element as a single node even if it's a subtree. * This is used instead of next() when the result has to be a * tree root node. Also prevents us from duplicating recently-added * children; e.g., ^(type ID)+ adds ID to type and then 2nd iteration * must dup the type node, but ID has been added. * * Referencing a rule result twice is ok; dup entire tree as * we can't be adding trees as root; e.g., expr expr. * * Hideous code duplication here with super.next(). Can't think of * a proper way to refactor. This needs to always call dup node * and super.next() doesn't know which to call: dup node or dup tree. */ public Object nextNode() { //System.out.println("nextNode: elements="+elements+", singleElement="+((Tree)singleElement).toStringTree()); int n = size(); if ( dirty || (cursor>=n && n==1) ) { // if out of elements and size is 1, dup (at most a single node // since this is for making root nodes). Object el = _next(); return adaptor.dupNode(el); } // test size above then fetch Object tree = _next(); //System.out.println("_next="+((Tree)tree).toStringTree()); Object el = adaptor.dupNode(tree); // dup just the root (want node here) return el; }
/** Treat next element as a single node even if it's a subtree. * This is used instead of next() when the result has to be a * tree root node. Also prevents us from duplicating recently-added * children; e.g., ^(type ID)+ adds ID to type and then 2nd iteration * must dup the type node, but ID has been added. * * Referencing a rule result twice is ok; dup entire tree as * we can't be adding trees as root; e.g., expr expr. * * Hideous code duplication here with super.next(). Can't think of * a proper way to refactor. This needs to always call dup node * and super.next() doesn't know which to call: dup node or dup tree. */ public Object nextNode() { //System.out.println("nextNode: elements="+elements+", singleElement="+((Tree)singleElement).toStringTree()); int n = size(); if ( dirty || (cursor>=n && n==1) ) { // if out of elements and size is 1, dup (at most a single node // since this is for making root nodes). Object el = _next(); return adaptor.dupNode(el); } // test size above then fetch Object tree = _next(); while (adaptor.isNil(tree) && adaptor.getChildCount(tree) == 1) tree = adaptor.getChild(tree, 0); //System.out.println("_next="+((Tree)tree).toStringTree()); Object el = adaptor.dupNode(tree); // dup just the root (want node here) return el; }
/** Treat next element as a single node even if it's a subtree. * This is used instead of next() when the result has to be a * tree root node. Also prevents us from duplicating recently-added * children; e.g., ^(type ID)+ adds ID to type and then 2nd iteration * must dup the type node, but ID has been added. * * Referencing a rule result twice is ok; dup entire tree as * we can't be adding trees as root; e.g., expr expr. * * Hideous code duplication here with super.next(). Can't think of * a proper way to refactor. This needs to always call dup node * and super.next() doesn't know which to call: dup node or dup tree. */ public Object nextNode() { //System.out.println("nextNode: elements="+elements+", singleElement="+((Tree)singleElement).toStringTree()); int n = size(); if ( dirty || (cursor>=n && n==1) ) { // if out of elements and size is 1, dup (at most a single node // since this is for making root nodes). Object el = _next(); return adaptor.dupNode(el); } // test size above then fetch Object tree = _next(); while (adaptor.isNil(tree) && adaptor.getChildCount(tree) == 1) tree = adaptor.getChild(tree, 0); //System.out.println("_next="+((Tree)tree).toStringTree()); Object el = adaptor.dupNode(tree); // dup just the root (want node here) return el; }
/** Treat next element as a single node even if it's a subtree. * This is used instead of next() when the result has to be a * tree root node. Also prevents us from duplicating recently-added * children; e.g., ^(type ID)+ adds ID to type and then 2nd iteration * must dup the type node, but ID has been added. * * Referencing a rule result twice is ok; dup entire tree as * we can't be adding trees as root; e.g., expr expr. * * Hideous code duplication here with super.next(). Can't think of * a proper way to refactor. This needs to always call dup node * and super.next() doesn't know which to call: dup node or dup tree. */ public Object nextNode() { //System.out.println("nextNode: elements="+elements+", singleElement="+((Tree)singleElement).toStringTree()); int n = size(); if ( dirty || (cursor>=n && n==1) ) { // if out of elements and size is 1, dup (at most a single node // since this is for making root nodes). Object el = _next(); return adaptor.dupNode(el); } // test size above then fetch Object tree = _next(); while (adaptor.isNil(tree) && adaptor.getChildCount(tree) == 1) tree = adaptor.getChild(tree, 0); //System.out.println("_next="+((Tree)tree).toStringTree()); Object el = adaptor.dupNode(tree); // dup just the root (want node here) return el; }
/** Treat next element as a single node even if it's a subtree. * This is used instead of next() when the result has to be a * tree root node. Also prevents us from duplicating recently-added * children; e.g., ^(type ID)+ adds ID to type and then 2nd iteration * must dup the type node, but ID has been added. * * Referencing a rule result twice is ok; dup entire tree as * we can't be adding trees as root; e.g., expr expr. * * Hideous code duplication here with super.next(). Can't think of * a proper way to refactor. This needs to always call dup node * and super.next() doesn't know which to call: dup node or dup tree. */ public Object nextNode() { //System.out.println("nextNode: elements="+elements+", singleElement="+((Tree)singleElement).toStringTree()); int n = size(); if ( dirty || (cursor>=n && n==1) ) { // if out of elements and size is 1, dup (at most a single node // since this is for making root nodes). Object el = _next(); return adaptor.dupNode(el); } // test size above then fetch Object tree = _next(); while (adaptor.isNil(tree) && adaptor.getChildCount(tree) == 1) tree = adaptor.getChild(tree, 0); //System.out.println("_next="+((Tree)tree).toStringTree()); Object el = adaptor.dupNode(tree); // dup just the root (want node here) return el; }
/** Treat next element as a single node even if it's a subtree. * This is used instead of next() when the result has to be a * tree root node. Also prevents us from duplicating recently-added * children; e.g., ^(type ID)+ adds ID to type and then 2nd iteration * must dup the type node, but ID has been added. * * Referencing a rule result twice is ok; dup entire tree as * we can't be adding trees as root; e.g., expr expr. * * Hideous code duplication here with super.next(). Can't think of * a proper way to refactor. This needs to always call dup node * and super.next() doesn't know which to call: dup node or dup tree. */ public Object nextNode() { //System.out.println("nextNode: elements="+elements+", singleElement="+((Tree)singleElement).toStringTree()); int n = size(); if ( dirty || (cursor>=n && n==1) ) { // if out of elements and size is 1, dup (at most a single node // since this is for making root nodes). Object el = _next(); return adaptor.dupNode(el); } // test size above then fetch Object tree = _next(); while (adaptor.isNil(tree) && adaptor.getChildCount(tree) == 1) tree = adaptor.getChild(tree, 0); //System.out.println("_next="+((Tree)tree).toStringTree()); Object el = adaptor.dupNode(tree); // dup just the root (want node here) return el; }