checkpoint
[sbp.git] / src / edu / berkeley / sbp / Sequence.java
index c3c259f..31d8f29 100644 (file)
@@ -50,14 +50,8 @@ public abstract class Sequence extends Element implements Iterable<Element> {
 
     ////////////////////////////////////////////////////////////////////////////////
 
-    public Element follow = null;
-    public final Topology follow() { return follow==null ? null : Atom.toAtom(follow); }
-
-    Topology toAtom() {
-        if (elements.length!=1)
-            throw new RuntimeException("cannot invoke toAtom() on a Sequence with " + elements.length + " elements: " + this);
-        return Atom.toAtom(elements[0]);
-    }
+    public Atom follow = null;
+    public final Topology follow() { return follow; }
 
     public Sequence and(Sequence s) { Sequence ret = dup(); ret.needs.add(s); s.needed.add(ret); return ret; }
     public Sequence not(Sequence s) { Sequence ret = dup(); ret.hates.add(s); s.hated.add(ret); return ret; }
@@ -80,10 +74,10 @@ public abstract class Sequence extends Element implements Iterable<Element> {
     }
 
     // DO NOT MESS WITH THE FOLLOWING LINE!!!
-    private Forest.Ref epsilonForm = null;
+    private Forest.Many epsilonForm = null;
     Forest epsilonForm() {
         if (epsilonForm!=null) return epsilonForm;
-        epsilonForm = new Forest.Ref();
+        epsilonForm = new Forest.Many();
         epsilonForm.merge(firstp().rewrite(null, false));
         return epsilonForm;
     }
@@ -184,7 +178,7 @@ public abstract class Sequence extends Element implements Iterable<Element> {
         public Constant(Element[] e, Object result) { super(e); this.result = result; }
         Sequence _clone() { return new Constant(elements, result); }
         public <T> Forest<T> postReduce(Input.Region loc, Forest<T>[] args, Position p) {
-            return (Forest<T>)Forest.leaf(loc, result);
+            return (Forest<T>)Forest.create(loc, result, null, false);
         }
         static class Drop extends Constant {
             Sequence _clone() { return new Drop(elements, lame); }