HashSet<Phase.Waiting> tail = new HashSet<Phase.Waiting>();
/** corresponds to a positions <i>between tokens</i> the input stream; same as Tomita's U_i's */
- public class Phase implements Invokable<State, Forest, GSS.Phase.Node> {
+ public class Phase implements Invokable<State, Forest, GSS.Phase.Node>, IntegerMappable {
+ public int toInt() { return pos+1; }
/** the token immediately after this phase */
public final Token token;
Forest res = null;
boolean ok = false;
for(Phase.Node n : hash.values()) {
- //if (n.holder().empty() && pos>0) continue;
if (token == null && n.state.isAccepting()) {
if (finalResult==null) finalResult = new Forest.Ref();
finalResult.merge(n.holder);
this.fe = fe;
this.state = state;
this.holder().merge(pending);
- //if (holder().empty()) throw new Error(holder()+"");
Phase start = parent==null ? null : parent.phase();
if (parent != null) parents().add(parent, true);
if (Phase.this.hash.get(code(state, start)) != null) throw new Error("severe problem!");
}
/** a single state in the LR table and the transitions possible from it */
- public class State implements Comparable<Table.State>, Iterable<Position> {
+ public class State implements Comparable<Table.State>, Iterable<Position>, IntegerMappable {
+ public int toInt() { return idx; }
+
/*
public boolean isResolvable(Token t) {
boolean found = false;
import edu.berkeley.sbp.*;
/** an implementation of Token for streams of Java <tt>char</tt> values */
-public class CharToken implements Token, IntegerTopology.IntegerMappable {
+public class CharToken implements Token, IntegerMappable {
// Public //////////////////////////////////////////////////////////////////////////////
import edu.berkeley.sbp.*;
/** implementation of <tt>Topology</tt> for any class for which there is a mapping to the <tt>int</tt>s */
-public class IntegerTopology<V extends IntegerTopology.IntegerMappable> implements Topology<V> {
+public class IntegerTopology<V extends IntegerMappable> implements Topology<V> {
private final Range.Set rs;
private static final IntegerTopology empty = new IntegerTopology();
return sb.toString();
}
*/
- public static interface IntegerMappable {
- public int toInt();
- }
}
final Object[][] v = new Object[size][]; v_.toArray(v);
return new VisitableMap<K,V>() {
public boolean contains(K k) {
- IntegerTopology.IntegerMappable im = (IntegerTopology.IntegerMappable)k;
+ IntegerMappable im = (IntegerMappable)k;
int asint = im.toInt();
for(int i=0; i<size; i++)
if (min[i] <= asint && max[i] >= asint && v[i].length > 0)
return false;
}
public <B,C> void invoke(K k, Invokable<V,B,C> ivbc, B b, C c) {
- IntegerTopology.IntegerMappable im = (IntegerTopology.IntegerMappable)k;
+ IntegerMappable im = (IntegerMappable)k;
int asint = im.toInt();
for(int i=0; i<size; i++) {
if (min[i] <= asint && max[i] >= asint) {