checkpoint
[sbp.git] / src / edu / berkeley / sbp / Sequence.java
index 9586f72..39e4b11 100644 (file)
@@ -35,8 +35,11 @@ public abstract class Sequence extends Element implements Iterable<Element> {
 
     ////////////////////////////////////////////////////////////////////////////////
 
+    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<Element> {
     protected Sequence(Element[] elements, HashSet<Sequence> and, HashSet<Sequence> not) {
         this.needs = and==null ? new HashSet<Sequence>() : and;
         this.hates = not==null ? new HashSet<Sequence>() : 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<Position> h) { firstp().reachable(h); }
-
     Forest epsilonForm() { return firstp().rewrite(null); }
 
     protected abstract <T> Forest<T> postReduce(Token.Location loc, Forest<T>[] args);
@@ -71,12 +70,6 @@ public abstract class Sequence extends Element implements Iterable<Element> {
     /** the imaginary position before or after an element of a sequence; corresponds to an "LR item" */
     public class Position {
 
-        void reachable(HashSet<Position> 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;