X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Fedu%2Fberkeley%2Fsbp%2FSequence.java;h=39e4b11a7854282273503f08939b798a3e5c269e;hb=b0d313eb49712b23f9c71003c96f130f23a63526;hp=a5149f2d094ef3dee1b4712f7bc67713eeb9650c;hpb=87f214f3da9f43c3ab93923313845c372f9a96be;p=sbp.git diff --git a/src/edu/berkeley/sbp/Sequence.java b/src/edu/berkeley/sbp/Sequence.java index a5149f2..39e4b11 100644 --- a/src/edu/berkeley/sbp/Sequence.java +++ b/src/edu/berkeley/sbp/Sequence.java @@ -35,11 +35,11 @@ public abstract class Sequence extends Element implements Iterable { //////////////////////////////////////////////////////////////////////////////// - public Topology noFollow() { return null; } + public Element noFollow = null; + public final Topology noFollow() { return noFollow==null ? null : noFollow.toAtom(); } Topology toAtom() { - if (elements.length>1) throw new RuntimeException("cannot invoke toAtom() on a Sequence with " + elements.length + " elements: " + this); - if (elements.length==0) return null; + if (elements.length!=1) throw new RuntimeException("cannot invoke toAtom() on a Sequence with " + elements.length + " elements: " + this); return elements[0].toAtom(); } @@ -56,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); @@ -74,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;