X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2Fmisc%2FCartesianInput.java;h=a78df9a5bcaf896fd39861e3f765c12497d0b2d1;hp=cf477ccc105bdafe3500f568049f3cb6c8f3aa65;hb=fc1e5069ec5401c425dd29b77b04285916b62d10;hpb=1177435c53540af2247a2fbd7b6fbcf059accbb8 diff --git a/src/edu/berkeley/sbp/misc/CartesianInput.java b/src/edu/berkeley/sbp/misc/CartesianInput.java index cf477cc..a78df9a 100644 --- a/src/edu/berkeley/sbp/misc/CartesianInput.java +++ b/src/edu/berkeley/sbp/misc/CartesianInput.java @@ -4,22 +4,22 @@ import java.util.*; import java.lang.reflect.*; import java.lang.ref.*; import edu.berkeley.sbp.*; -import edu.berkeley.sbp.Token.Location; +import edu.berkeley.sbp.Input.Location; import edu.berkeley.sbp.util.*; -public abstract class CartesianInput implements Token.Stream { +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 Token.Location location = new LocWrap(line, col); - public Token.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 implements Token.Stream { } else { col++; } - location = new LocWrap(line, col); + location = new CartesianLocation(line, col); return t; } - - public static class Location implements Token.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 Token.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; } - } }