checkpoint
[sbp.git] / src / edu / berkeley / sbp / Forest.java
index bdaedca..353e256 100644 (file)
@@ -158,6 +158,14 @@ public abstract class Forest<NodeType> implements GraphViz.ToGraphViz {
         
         void gather(HashSet<Forest<NodeType>> ht) {
             touched();
+
+            // FIXME: do something more sensible here
+            if (ht.contains(this)) {
+                System.err.println("WARNING: grammar produced a circular forest\n" + this);
+                //throw new Error("grammar produced a circular forest:\n" + this);
+                return;
+            }
+
             ht.add(this);
             for(Forest<NodeType> f : hp) f.gather(ht);
         }