corrected the reporting+alignment of error locations
[sbp.git] / src / edu / berkeley / sbp / Forest.java
index 4f79bb6..ee3bfbc 100644 (file)
@@ -34,7 +34,8 @@ public abstract class Forest<NodeType> implements GraphViz.ToGraphViz {
     abstract void gather(HashSet<Forest<NodeType>> ignore);
     abstract void edges(GraphViz.Node n);
     boolean ambiguous() { return false; }
-
+    
+    abstract Input.Region getRegion();
 
     // One //////////////////////////////////////////////////////////////////////////////
 
@@ -48,6 +49,8 @@ public abstract class Forest<NodeType> implements GraphViz.ToGraphViz {
         /** if true, the last child's children are considered children of this node */
         private final boolean           lift;
 
+        Input.Region getRegion() { return location; }
+
         private One(Input.Region loc, NodeType head, Forest<NodeType>[] children, boolean lift) {
             this.location = loc;
             this.head = head;
@@ -129,6 +132,8 @@ public abstract class Forest<NodeType> implements GraphViz.ToGraphViz {
 
         public Many() { }
 
+        Input.Region getRegion() { return hp.iterator().next().getRegion(); } // all should be identical
+
         public Tree<NodeType> expand1() throws Ambiguous {
             touched();
             if (hp.size() > 1) {