checkpoint
[sbp.git] / src / edu / berkeley / sbp / Walk.java
index cd991e8..a82cf52 100644 (file)
@@ -37,7 +37,13 @@ abstract class Walk<T> {
         else if (e instanceof Sequence) return sequence((Sequence)e);
         else if (e instanceof Union) {
             T ret = bottom(e);
-            for(Sequence s : (Union)e) ret = union((Union)e, ret, walk(s));
+            for(Sequence s : (Union)e) {
+                ret = union((Union)e, ret, walk(s));
+
+                // FIXME
+                for(Sequence ss : s.needs()) ret = union((Union)e, ret, walk(ss));
+                for(Sequence ss : s.hates()) ret = union((Union)e, ret, walk(ss));
+            }
             return ret;
         } else {
             throw new Error("unknown element of class " + e.getClass().getName() + ": " + e);
@@ -82,7 +88,7 @@ abstract class Walk<T> {
         public WalkTokenSet(Topology<Tok> cs)          { this.cs = cs; }
         public WalkTokenSet(Topology<Tok> cs, Cache c) { super(c); this.cs = cs; }
         public Topology<Tok> bottom(Element e)         { return cs; }
-        public Topology<Tok> walkAtom(Atom r)          { cs = cs.union(r); return cs; }
+        public Topology<Tok> walkAtom(Atom r)          { cs = cs.union(r.getTokenTopology()); return cs; }
     }
 
     static class First<Tok extends Input> extends WalkTokenSet<Tok> {
@@ -149,7 +155,7 @@ abstract class Walk<T> {
 
             if (e instanceof Sequence) {
                 Sequence s = (Sequence)e;
-                if (s.follow() != null) cs = cs.intersect(s.follow());
+                if (s.follow != null) cs = cs.intersect(s.follow.getTokenTopology());
             }
 
             if (c != null && e==me) {