checkpoint
[sbp.git] / src / edu / berkeley / sbp / Sequence.java
index 61a18e8..0ac3500 100644 (file)
@@ -85,7 +85,7 @@ public abstract class Sequence extends Element implements Iterable<Element> {
         return epsilonForm;
     }
 
-    protected abstract <T> Forest<T> postReduce(Input.Location loc, Forest<T>[] args, Position p);
+    protected abstract <T> Forest<T> postReduce(Input.Region loc, Forest<T>[] args, Position p);
 
 
     // Position //////////////////////////////////////////////////////////////////////////////
@@ -127,8 +127,8 @@ public abstract class Sequence extends Element implements Iterable<Element> {
 
         // Position /////////////////////////////////////////////////////////////////////////////////
 
-        final <T> Forest<T> rewrite(Input.Location loc) { return rewrite(loc, true); }
-        private final <T> Forest<T> rewrite(Input.Location loc, boolean epsilonCheck) {
+        final <T> Forest<T> rewrite(Input.Region loc) { return rewrite(loc, true); }
+        private final <T> Forest<T> rewrite(Input.Region loc, boolean epsilonCheck) {
             if (epsilonCheck && this==firstp()) return epsilonForm();
             for(int i=0; i<pos; i++) if (holder[i]==null) throw new Error("realbad " + i);
             for(int i=pos; i<elements.length; i++) {
@@ -180,7 +180,7 @@ public abstract class Sequence extends Element implements Iterable<Element> {
         private final Object result;
         public Constant(Element[] e, Object result) { super(e); this.result = result; }
         Sequence _clone() { return new Constant(elements, result); }
-        public <T> Forest<T> postReduce(Input.Location loc, Forest<T>[] args, Position p) {
+        public <T> Forest<T> postReduce(Input.Region loc, Forest<T>[] args, Position p) {
             return (Forest<T>)Forest.leaf(loc, result, p);
         }
         static class Drop extends Constant {
@@ -199,7 +199,7 @@ public abstract class Sequence extends Element implements Iterable<Element> {
         private final int idx;
         public Singleton(Element e) { this(new Element[] { e }, 0); }
         public Singleton(Element[] e, int idx) { super(e); this.idx = idx; }
-        public <T> Forest<T> postReduce(Input.Location loc, Forest<T>[] args, Position p) { return (Forest<T>)Forest.singleton(loc, args[idx], p); }
+        public <T> Forest<T> postReduce(Input.Region loc, Forest<T>[] args, Position p) { return (Forest<T>)Forest.singleton(loc, args[idx], p); }
         Sequence _clone() { return new Singleton(elements,idx); }
     }
 
@@ -210,7 +210,7 @@ public abstract class Sequence extends Element implements Iterable<Element> {
         public Unwrap(Element[] e, Object tag)                  { super(e); this.drops = null; this.tag = tag; }
         public Unwrap(Element[] e, Object tag, boolean[] drops) { super(e); this.drops = drops; this.tag = tag; }
         Sequence _clone() { return new Unwrap(elements, drops); }
-        public <T> Forest<T> postReduce(Input.Location loc, Forest<T>[] args, Position p) {
+        public <T> Forest<T> postReduce(Input.Region loc, Forest<T>[] args, Position p) {
             for(int i=0; i<args.length; i++) if (args[i]==null) throw new Error();
             if (drops==null) return Forest.create(loc, (T)tag, args, true, false, p);
             int count = 0;
@@ -234,7 +234,7 @@ public abstract class Sequence extends Element implements Iterable<Element> {
             this.drops = drops == null ? new boolean[e.length] : drops;
             for(int i=0; i<this.drops.length; i++) if (!this.drops[i]) count++;
         }
-        public <T> Forest<T> postReduce(Input.Location loc, Forest<T>[] args, Position p) {
+        public <T> Forest<T> postReduce(Input.Region loc, Forest<T>[] args, Position p) {
             Forest<T>[] args2 = new Forest[count];
             int j = 0;
             for(int i=0; i<args.length; i++) if (!drops[i]) args2[j++] = args[i];