X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Fedu%2Fberkeley%2Fsbp%2FSequence.java;h=39e4b11a7854282273503f08939b798a3e5c269e;hb=7fbee73b4dd985cb5b217ed297710c00fd9d7004;hp=9586f728e1e5df391de200cfd00d1c090b751e2d;hpb=2690f6c749f117a103c57d651d89f1b4fbf1316d;p=sbp.git diff --git a/src/edu/berkeley/sbp/Sequence.java b/src/edu/berkeley/sbp/Sequence.java index 9586f72..39e4b11 100644 --- a/src/edu/berkeley/sbp/Sequence.java +++ b/src/edu/berkeley/sbp/Sequence.java @@ -35,8 +35,11 @@ public abstract class Sequence extends Element implements Iterable { //////////////////////////////////////////////////////////////////////////////// + public Element noFollow = null; + public final Topology noFollow() { return noFollow==null ? null : noFollow.toAtom(); } + Topology toAtom() { - if (elements.length!=1) return null; + if (elements.length!=1) throw new RuntimeException("cannot invoke toAtom() on a Sequence with " + elements.length + " elements: " + this); return elements[0].toAtom(); } @@ -53,14 +56,10 @@ public abstract class Sequence extends Element implements Iterable { protected Sequence(Element[] elements, HashSet and, HashSet not) { this.needs = and==null ? new HashSet() : and; this.hates = not==null ? new HashSet() : not; - //for(Sequence s : needs) s.lame = true; - //for(Sequence s : hates) s.lame = true; this.elements = elements; this.firstp = new Position(0); } - void reachable(HashSet h) { firstp().reachable(h); } - Forest epsilonForm() { return firstp().rewrite(null); } protected abstract Forest postReduce(Token.Location loc, Forest[] args); @@ -71,12 +70,6 @@ public abstract class Sequence extends Element implements Iterable { /** the imaginary position before or after an element of a sequence; corresponds to an "LR item" */ public class Position { - void reachable(HashSet h) { - if (h.contains(this)) return; - h.add(this); - if (element() != null) element().reachable(h); - } - final int pos; private final Position next; final Forest[] holder;