X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FForest.java;h=b2f4a2239f3b641e52ec7031ec466deed810e267;hb=61539aaf02d0537fd1df08b5d5bd03189992cf1e;hp=bdaedca81f52d6967d3033d1c1fc4137cb1e800b;hpb=3ee451bce342d4bb61ad6235ba57bdf817bfdd1a;p=sbp.git diff --git a/src/edu/berkeley/sbp/Forest.java b/src/edu/berkeley/sbp/Forest.java index bdaedca..b2f4a22 100644 --- a/src/edu/berkeley/sbp/Forest.java +++ b/src/edu/berkeley/sbp/Forest.java @@ -129,7 +129,6 @@ public abstract class Forest implements GraphViz.ToGraphViz { /** An "ambiguity node"; this is immutable once it has been "looked at" */ static class Many extends Forest { - HashSet parents = new HashSet(); private FastSet> hp = new FastSet>(); private boolean touched = false; @@ -158,6 +157,14 @@ public abstract class Forest implements GraphViz.ToGraphViz { void gather(HashSet> 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 f : hp) f.gather(ht); }