X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2Fmisc%2FCartesianInput.java;fp=src%2Fedu%2Fberkeley%2Fsbp%2Fmisc%2FCartesianInput.java;h=a78df9a5bcaf896fd39861e3f765c12497d0b2d1;hb=fc1e5069ec5401c425dd29b77b04285916b62d10;hp=928b236f8e31ac0be0fb31267279127509d29181;hpb=c7af09d552a9cf2d53a72baa975c9a73384813ea;p=sbp.git diff --git a/src/edu/berkeley/sbp/misc/CartesianInput.java b/src/edu/berkeley/sbp/misc/CartesianInput.java index 928b236..a78df9a 100644 --- a/src/edu/berkeley/sbp/misc/CartesianInput.java +++ b/src/edu/berkeley/sbp/misc/CartesianInput.java @@ -7,19 +7,19 @@ import edu.berkeley.sbp.*; import edu.berkeley.sbp.Input.Location; import edu.berkeley.sbp.util.*; -public abstract class CartesianInput implements Input { +public abstract class CartesianInput implements Input { - 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,14 +35,7 @@ public abstract class CartesianInput implements Input { } else { col++; } - location = new LocWrap(line, col); + location = new CartesianLocation(line, col); return t; } - - 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; } - } }