+++ /dev/null
-package edu.berkeley.sbp.misc;
-import java.io.*;
-import java.util.*;
-import java.lang.reflect.*;
-import java.lang.ref.*;
-import edu.berkeley.sbp.*;
-import edu.berkeley.sbp.Input.Location;
-import edu.berkeley.sbp.util.*;
-
-public abstract class CartesianInput<Token> implements Input<Token> {
-
- public abstract Token next() throws IOException;
- public abstract boolean isCR();
-
- long then = 0;
- private Input.Location.Cartesian location = new Input.Location.Cartesian(0, 1);
- public Input.Location getLocation() { return location; }
-
- public Token next(int numstates, int resets, int waits) throws IOException {
- int line = location.getRow();
- int col = location.getCol();
- Token t = next();
- if (t==null) return null;
- String s = " line "+line+", col " + col;
- while(s.length() < 20) s += " ";
- s += "[ambiguity level: " + (numstates-1) + "] [resets: " + resets + "] [waits: " + waits + "]";
- long now = System.currentTimeMillis();
- if (now-then > 10) {
- then = now;
- System.out.print(s + " \r");
- }
- if (isCR()) {
- line++;
- col = 1;
- } else {
- col++;
- }
- location = new Input.Location.Cartesian(col, line);
- return t;
- }
-}