X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FTree.java;h=220d1ddc0574977bf5a160c41e090328f8cc9f4f;hp=b8677669bd71709c84d29c4b4c28cd7b91eae2e5;hb=b318adb49d46a596314d7b7c0dd9f52681abb449;hpb=d95659dd73e9dee2d18417535e4c7d5a010033b6 diff --git a/src/edu/berkeley/sbp/Tree.java b/src/edu/berkeley/sbp/Tree.java index b867766..220d1dd 100644 --- a/src/edu/berkeley/sbp/Tree.java +++ b/src/edu/berkeley/sbp/Tree.java @@ -11,6 +11,7 @@ public class Tree extends PrintableTree> implements Iterable> final T head; Tree[] children; + Object[] labels; final Input.Location location; public T head() { return head; } @@ -18,16 +19,23 @@ public class Tree extends PrintableTree> implements Iterable> public Iterable> children() { return new ArrayIterator(children); } public Iterator> iterator() { return new ArrayIterator(children); } public Tree child(int i) { return children[i]; } + public Object label(int i) { return labels[i]; } - public Input.Location getLocation() { return location; } + public Input.Location getLocation() { return location; } public Tree(Input.Location loc, T head) { this(loc, head, null); } - public Tree(Input.Location loc, T head, Tree[] children) { + public Tree(Input.Location loc, T head, Tree[] children) { this(loc, head, children, null); } + public Tree(Input.Location loc, T head, Tree[] children, Object[] labels) { this.location = loc; this.head = head; + Tree[] children2 = children==null ? new Tree[0] : new Tree[children.length]; if (children != null) System.arraycopy(children, 0, children2, 0, children.length); this.children = children2; + + Object[] labels2 = labels==null ? new Object[0] : new Object[labels.length]; + if (labels != null) System.arraycopy(labels, 0, labels2, 0, labels.length); + this.labels = labels2; } protected String headToString() { return head==null?null:head.toString(); }