1 package edu.berkeley.sbp.misc;
4 import java.lang.reflect.*;
5 import java.lang.ref.*;
6 import edu.berkeley.sbp.*;
7 import edu.berkeley.sbp.Token.Location;
8 import edu.berkeley.sbp.util.*;
10 public abstract class CartesianInput<Tok> implements Token.Stream<Tok> {
15 public abstract Tok next() throws IOException;
16 public abstract boolean isCR();
19 private Token.Location location = new LocWrap(line, col);
20 public Token.Location getLocation() { return location; }
21 public Tok next(int numstates, int resets, int waits) throws IOException {
23 if (t==null) return null;
24 String s = " line "+line+", col " + col;
25 while(s.length() < 20) s += " ";
26 s += "[ambiguity level: " + (numstates-1) + "] [resets: " + resets + "] [waits: " + waits + "]";
27 long now = System.currentTimeMillis();
30 System.out.print(s + " \r");
38 location = new LocWrap(line, col);
42 public static class Location implements Token.Location {
43 public final int line;
45 public String toString() { return line + ":" + col; }
46 public Location(int line, int col) { this.line = line; this.col = col; }
49 private class LocWrap implements Token.Location {
50 public final int line;
52 public String toString() { return line + ":" + col; }
53 public LocWrap(int line, int col) { this.line = line; this.col = col; }