X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FForest.java;h=643734147623c7db7e735d7b2bbf984a84aa0d6d;hp=ed1c9aca4cec39a673b85e48edc65f715b41d478;hb=014de68a21aa2d17fdfd0bac7e404a725997a246;hpb=7fbee73b4dd985cb5b217ed297710c00fd9d7004 diff --git a/src/edu/berkeley/sbp/Forest.java b/src/edu/berkeley/sbp/Forest.java index ed1c9ac..6437341 100644 --- a/src/edu/berkeley/sbp/Forest.java +++ b/src/edu/berkeley/sbp/Forest.java @@ -32,7 +32,7 @@ public abstract class Forest { protected static class Body { - private final Token.Location location; + private final Token.Location location; private final T tag; private final Forest[] tokens; private final Sequence creator; @@ -144,7 +144,7 @@ public abstract class Forest { } public Iterator> iterator() { return ((IterableForest)resolve()).iterator(); } public HashSet> expand(boolean toss) { return resolve().expand(toss); } - public boolean valid() { resolve(); return valid; } + public boolean valid() { if (valid) return true; resolve(); return valid; } public String toString() { return resolve().toString(); } public Forest resolve() { if (hp==null) return res; @@ -156,11 +156,13 @@ public abstract class Forest { else results = new HashSet(); } if (results != null) { - for(Forest p : hp) for(Body b : (IterableForest)p) results.add(b); + for(Forest p : hp) + for(Body b : (IterableForest)p) + results.add(b); for(Body b : results) { if (b.keep() && (b.creator==null || !b.creator.lame)) continue; - if (!b.keep(results)) continue; if (b.creator!=null && b.creator.lame) continue; + if (!b.keep(results)) continue; valid = true; b.addTo(nh); }