1 package edu.berkeley.sbp;
4 import java.lang.reflect.*;
5 import java.lang.ref.*;
6 import edu.berkeley.sbp.*;
7 import edu.berkeley.sbp.util.*;
9 /** a stream of tokens to be parsed */
10 public interface Input<Token> {
12 /** returns the token just beyond the current location and advances beyond it */
13 public Token next() throws IOException;
15 /** returns the location the input stream is currently at */
16 public Location<Token> getLocation();
18 /** a location <i>between tokens<i> in the input stream */
19 public static interface Location<Tok> extends Comparable<Location> {
20 public String toString();
23 public static class Region<Loc extends Location> /* implements Topology<Location<Tok>> */ {
24 public final Loc start;
26 public Region(Loc a, Loc b) {
27 switch(a.compareTo(b)) {
29 case 0: start=a; end=b; return;
30 case 1: start=b; end=a; return;
31 default: throw new Error("impossible");