X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FSequence.java;h=b33279352a9a6b61c4cfd4bfa3e29629c3670e6f;hp=a5149f2d094ef3dee1b4712f7bc67713eeb9650c;hb=96a2822a729e563a64173f22dc184bc972a200ef;hpb=87f214f3da9f43c3ab93923313845c372f9a96be diff --git a/src/edu/berkeley/sbp/Sequence.java b/src/edu/berkeley/sbp/Sequence.java index a5149f2..b332793 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(); } @@ -62,8 +62,6 @@ public abstract class Sequence extends Element implements Iterable { 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 +72,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;