checkpoint
[sbp.git] / src / edu / berkeley / sbp / misc / CartesianInput.java
index 4930173..a78df9a 100644 (file)
@@ -7,19 +7,19 @@ import edu.berkeley.sbp.*;
 import edu.berkeley.sbp.Input.Location;
 import edu.berkeley.sbp.util.*;
 
-public abstract class CartesianInput<Tok> implements Input<Tok> {
+public abstract class CartesianInput<Token> implements Input<Token> {
 
-    private int line  = 1;
-    private int col   = 0;
-
-    public abstract Tok     next() throws IOException;
+    public abstract Token   next() throws IOException;
     public abstract boolean isCR();
 
     long then = 0;
-    private Input.Location location = new LocWrap(line, col);
-    public Input.Location getLocation() { return location; }
-    public Tok next(int numstates, int resets, int waits) throws IOException {
-        Tok t = next();
+    private CartesianLocation location = new CartesianLocation(1, 0);
+    public  Input.Location    getLocation() { return location; }
+
+    public Token next(int numstates, int resets, int waits) throws IOException {
+        int line  = location.line;
+        int col   = location.col;
+        Token t = next();
         if (t==null) return null;
         String s = "  line "+line+", col " + col;
         while(s.length() < 20) s += " ";
@@ -35,21 +35,7 @@ public abstract class CartesianInput<Tok> implements Input<Tok> {
         } else {
             col++;
         }
-        location = new LocWrap(line, col);
+        location = new CartesianLocation(line, col);
         return t;
     }
-
-    public static class Location implements Input.Location {
-        public final int line;
-        public final int col;
-        public String toString()            { return line + ":" + col; }
-        public Location(int line, int col)  { this.line = line; this.col = col; }
-    }
-
-    private class LocWrap implements Input.Location {
-        public final int line;
-        public final int col;
-        public String toString()            { return line + ":" + col; }
-        public LocWrap(int line, int col) { this.line = line; this.col = col; }
-    }
 }