public int resets = 0;
public int waits = 0;
- HashMapBag<Integer,Sequence> inhibited = new HashMapBag<Integer,Sequence>();
- HashMapBag<Integer,Sequence> assumed = new HashMapBag<Integer,Sequence>();
+ HashMapBag<Integer,Sequence> inhibited = new HashMapBag<Integer,Sequence>();
HashMapBag<Sequence,Phase.Waiting> waiting = new HashMapBag<Sequence,Phase.Waiting>();
- HashMapBag<Integer,Sequence> performed = new HashMapBag<Integer,Sequence>();
- HashSet<Phase.Waiting> tail = new HashSet<Phase.Waiting>();
+ HashMapBag<Integer,Sequence> performed = new HashMapBag<Integer,Sequence>();
/** 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>, IntegerMappable {
this.token = token;
this.location = location;
inhibited.clear();
- assumed.clear();
reset();
}
public void reset() {
- tail.clear();
waiting.clear();
performed.clear();
hash = new IntPairMap<Phase.Node>();
if (n.touched) return;
n.touched = true;
for(Position p : n.state) {
- //if (!p.isLast()) {
if (((p.isFirst() || p.isLast()) && !force) || p.owner().name==null) {
for(Node n2 : n.parents())
complain(n2, errors, force | p.isFirst());
HashSet<String> hs = errors.get(seqname);
if (hs==null) errors.put(seqname, hs = new HashSet<String>());
hs.add(p.element()+"");
- //String s = " while parsing " + seqname + ": expected a " + p.element();
- //"\n";
- /*
- s += " parsed: ";
- for(Position p2 = p.owner().firstp(); p2 != null && p2 != p && !p2.isLast(); p2 = p2.next()) s += (p2.element() + " ");
- s += "\n";
- s += " expected: ";
- for(Position p2 = p; p2 != null && !p2.isLast(); p2 = p2.next()) s += (p2.element() + " ");
- */
- //s += "\n";
- //errors.add(s);
}
}
}
Sequence owner = reduction==null ? null : reduction.position.owner();
if (reduction!=null) {
if (inhibited.contains(pos, owner)) return;
- /*
- if (assumed.contains(pos, owner)) {
- tail.add(new Waiting(parent, pending, state, fromEmptyReduction, reduction));
- return;
- }
- */
if (owner.needs != null)
for(Sequence s : owner.needs)
if (!performed.contains(pos, s)) {
if (token != null && state.canShift(token)) break;
if (state.isAccepting()) break;
if (token==null) break;
- //if (!state.canReduce(token)) return false;
+ if (!state.canReduce(token)) return false;
//if (count > 1) break;
//if (r.numPop == 0) break;
//r.reduce(pending, parent, null, Phase.this, null);
//System.out.println("\nresetting due to " + r.position.owner() + " killing " + seq);
//inhibited.clear();
inhibited.add(p, seq);
- //assumed = inhibited;
//inhibited = new HashMapBag<Integer,Sequence>();
reset = true;
resets++;
reducing_list[i] = null;
n.queueReductions();
}
- //for(Waiting w : tail)
- //w.perform();
} catch (Reset r) {
reset();
reduce();