From d93afe731bf19f7dbf6be40f916672d9c200b947 Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 22 Jan 2006 04:30:11 -0500 Subject: [PATCH] checkpoint darcs-hash:20060122093011-5007d-388cde3e541b353df39172e236b03a615e6d4084.gz --- src/edu/berkeley/sbp/Forest.java | 20 ++++++++++++-------- src/edu/berkeley/sbp/util/FastSet.java | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/edu/berkeley/sbp/Forest.java b/src/edu/berkeley/sbp/Forest.java index 4f4baac..786ffad 100644 --- a/src/edu/berkeley/sbp/Forest.java +++ b/src/edu/berkeley/sbp/Forest.java @@ -19,7 +19,7 @@ public abstract class Forest /*extends PrintableTree>*/ impl /** expand this forest into a set of trees */ public HashSet> expand(boolean toss) { TreeMaker ret = new TreeMaker(); - invoke(ret, new Boolean(toss), null); + visit(ret, new Boolean(toss), null); if (toss && ret.size() > 1) throw new Ambiguous(this); return ret; } @@ -37,11 +37,14 @@ public abstract class Forest /*extends PrintableTree>*/ impl TreeMaker expand(boolean toss, int i, TreeMaker h); } - protected static class MyBody extends Forest implements Body /* extends PrintableTree> implements */ { + protected static class MyBody extends Forest implements Body /* extends PrintableTree> implements *//*, Invokable>*/ { - public void invoke(Invokable,B,C> ivbc, B b, C c) { + public void visit(Invokable,B,C> ivbc, B b, C c) { ivbc.invoke(this, b, c); } + public void invoke(Tree ivbc, B b, C c) { + //ivbc.invoke(this, b, c); + } private final Input.Location location; private final T tag; @@ -61,17 +64,18 @@ public abstract class Forest /*extends PrintableTree>*/ impl public TreeMaker expand(boolean toss, int i, TreeMaker h) { if (singleton) { - tokens[0].invoke(h, toss, i); + tokens[0].visit(h, toss, i); } else if (i==tokens.length) { h.add(new Tree(null, tag, h.toks.toArray(tree_hint))); } else if (unwrap && i==tokens.length-1) { if (tokens[i] != null) - tokens[i].invoke(h, toss, 0); + tokens[i].visit(h, toss, 0); } else { boolean hit = false; + //tokens[i].visit(this, for(Tree r : tokens[i].expand(toss)) { hit = true; int old = h.toks.size(); @@ -103,14 +107,14 @@ public abstract class Forest /*extends PrintableTree>*/ impl private FastSet> hp = new FastSet>(); public Ref() { } public void merge(Forest p) { if (p!=this) hp.add(p, true); } - public void invoke(Invokable,B,C> ivbc, B b, C c) { + public void visit(Invokable,B,C> ivbc, B b, C c) { if (hp==null) return; - for(Forest f : hp) f.invoke(ivbc, b, c); + for(Forest f : hp) f.visit(ivbc, b, c); } public Forest resolve() { return this; } } - public abstract void invoke(Invokable,B,C> ivbc, B b, C c); + public abstract void visit(Invokable,B,C> ivbc, B b, C c); private static class TreeMaker extends HashSet> implements Invokable,Boolean,Integer> { public ArrayList> toks = new ArrayList>(); public void invoke(Forest.Body bod, Boolean toss, Integer i) { diff --git a/src/edu/berkeley/sbp/util/FastSet.java b/src/edu/berkeley/sbp/util/FastSet.java index 1e6c6d5..e7ae063 100644 --- a/src/edu/berkeley/sbp/util/FastSet.java +++ b/src/edu/berkeley/sbp/util/FastSet.java @@ -28,7 +28,7 @@ public /*final*/ class FastSet implements Iterator, Iterable, Visitable for(T t : s) array[size++] = t; } - public void invoke(Invokable ivbc, B b, C c) { + public void visit(Invokable ivbc, B b, C c) { if (only!=null) ivbc.invoke(only, b, c); else for(int j=0; j