- public Tree(Input.Location loc, T head) { this(loc, head, null); }
- public Tree(Input.Location loc, T head, Tree<T>[] children) {
+ public int numChildren() {
+ return lift
+ ? (children.length-1)+lifted().numChildren()
+ : children.length;
+ }
+ public Iterable<Tree<T>> children() { return this; }
+ public Iterator<Tree<T>> iterator() {
+ return lift
+ ? new ConcatenateIterator(new ArrayIterator(children, 0, children.length-1),
+ children[children.length-1].iterator())
+ : new ArrayIterator(children);
+ }
+
+ public Tree<T> child(int i) {
+ return lift && i >= children.length-1
+ ? children[children.length-1].child(i-(children.length-1))
+ : children[i];
+ }
+
+ public Input.Region getRegion() { return location; }
+
+ public Tree(Input.Region loc, T head) { this(loc, head, null); }
+ public Tree(Input.Region loc, T head, Tree<T>[] children) { this(loc, head, children, false); }
+ public Tree(Input.Region loc, T head, Tree<T>[] children, boolean lift) {