projects
/
sbp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
c8d1c3a
)
checkpoint
author
adam
<adam@megacz.com>
Sun, 16 Jul 2006 07:36:44 +0000
(
03:36
-0400)
committer
adam
<adam@megacz.com>
Sun, 16 Jul 2006 07:36:44 +0000
(
03:36
-0400)
darcs-hash:
20060716073644
-5007d-
87e7c4c7a28a18ab4aec6eff9a1e9cfa96c39d1c
.gz
TODO
patch
|
blob
|
history
src/edu/berkeley/sbp/Forest.java
patch
|
blob
|
history
diff --git
a/TODO
b/TODO
index
bed7ed8
..
f3b6476
100644
(file)
--- a/
TODO
+++ b/
TODO
@@
-2,6
+2,7
@@
_____________________________________________________________________________
Immediately
- do Forest/Tree still need a Region?
Immediately
- do Forest/Tree still need a Region?
+ - the unwrap bit in Forest makes it really hard to expose an API for forests
- evil problems with (x y? z /ws)
- ParseFailed, GSS, Walk, Parser, Sequence, Forest
- evil problems with (x y? z /ws)
- ParseFailed, GSS, Walk, Parser, Sequence, Forest
diff --git
a/src/edu/berkeley/sbp/Forest.java
b/src/edu/berkeley/sbp/Forest.java
index
0fb10c6
..
1c8fbc5
100644
(file)
--- a/
src/edu/berkeley/sbp/Forest.java
+++ b/
src/edu/berkeley/sbp/Forest.java
@@
-12,7
+12,6
@@
import java.lang.reflect.*;
*/
public abstract class Forest<T> implements GraphViz.ToGraphViz {
*/
public abstract class Forest<T> implements GraphViz.ToGraphViz {
-
/** assume that this forest contains exactly one tree and return it; otherwise throw an exception */
public abstract Tree<T> expand1() throws Ambiguous;
/** assume that this forest contains exactly one tree and return it; otherwise throw an exception */
public abstract Tree<T> expand1() throws Ambiguous;
@@
-24,7
+23,6
@@
public abstract class Forest<T> implements GraphViz.ToGraphViz {
return new One<T>(loc, head, children, unwrap);
}
return new One<T>(loc, head, children, unwrap);
}
-
// Package-Private //////////////////////////////////////////////////////////////////////////////
abstract void expand(HashSet<Tree<T>> ht, HashSet<Forest<T>> ignore, Tree<T> bogus);
// Package-Private //////////////////////////////////////////////////////////////////////////////
abstract void expand(HashSet<Tree<T>> ht, HashSet<Forest<T>> ignore, Tree<T> bogus);
@@
-37,7
+35,7
@@
public abstract class Forest<T> implements GraphViz.ToGraphViz {
// One //////////////////////////////////////////////////////////////////////////////
/** A "single" forest with a head and child subforests */
// One //////////////////////////////////////////////////////////////////////////////
/** A "single" forest with a head and child subforests */
- public static class One<T> extends Forest<T> {
+ private static class One<T> extends Forest<T> {
private final Input.Region location;
private final T head;
private final Input.Region location;
private final T head;
@@
-61,11
+59,11
@@
public abstract class Forest<T> implements GraphViz.ToGraphViz {
return new Tree<T>(location, head, ret, unwrap);
}
return new Tree<T>(location, head, ret, unwrap);
}
- public void gather(HashSet<Forest<T>> hf) {
+ void gather(HashSet<Forest<T>> hf) {
hf.add(this);
for(Forest<T> f : children) f.gather(hf);
}
hf.add(this);
for(Forest<T> f : children) f.gather(hf);
}
- public void expand(HashSet<Tree<T>> ht, HashSet<Forest<T>> ignore, Tree<T> bogus) {
+ void expand(HashSet<Tree<T>> ht, HashSet<Forest<T>> ignore, Tree<T> bogus) {
if (ignore.contains(this)) { ht.add(bogus); return; }
expand(0, new Tree[children.length], ht, ignore, bogus);
}
if (ignore.contains(this)) { ht.add(bogus); return; }
expand(0, new Tree[children.length], ht, ignore, bogus);
}
@@
-95,7
+93,7
@@
public abstract class Forest<T> implements GraphViz.ToGraphViz {
edges(n);
return n;
}
edges(n);
return n;
}
- boolean edges = false;
+ boolean edges = false; // FIXME ??
public void edges(GraphViz.Node n) {
if (edges) return;
edges = true;
public void edges(GraphViz.Node n) {
if (edges) return;
edges = true;
@@
-119,7
+117,7
@@
public abstract class Forest<T> implements GraphViz.ToGraphViz {
// Many //////////////////////////////////////////////////////////////////////////////
/** An "ambiguity node"; this is immutable once it has been "looked at" */
// Many //////////////////////////////////////////////////////////////////////////////
/** An "ambiguity node"; this is immutable once it has been "looked at" */
- public static class Many<T> extends Forest<T> implements Iterable<One<T>> {
+ static class Many<T> extends Forest<T> {
HashSet<GSS.Phase.Node> parents = new HashSet<GSS.Phase.Node>();
private FastSet<Forest<T>> hp = new FastSet<Forest<T>>();
HashSet<GSS.Phase.Node> parents = new HashSet<GSS.Phase.Node>();
private FastSet<Forest<T>> hp = new FastSet<Forest<T>>();
@@
-127,11
+125,6
@@
public abstract class Forest<T> implements GraphViz.ToGraphViz {
public Many() { }
public Many() { }
- public Iterator<One<T>> iterator() {
- touched();
- return (Iterator<One<T>>)(Object)hp.iterator(); // FIXME: fastset's iterator is not safe!
- }
-
public Tree<T> expand1() throws Ambiguous {
touched();
if (hp.size() > 1) {
public Tree<T> expand1() throws Ambiguous {
touched();
if (hp.size() > 1) {
@@
-151,7
+144,7
@@
public abstract class Forest<T> implements GraphViz.ToGraphViz {
return hp.iterator().next().expand1();
}
return hp.iterator().next().expand1();
}
- public void gather(HashSet<Forest<T>> ht) {
+ void gather(HashSet<Forest<T>> ht) {
touched();
ht.add(this);
for(Forest<T> f : hp) f.gather(ht);
touched();
ht.add(this);
for(Forest<T> f : hp) f.gather(ht);
@@
-160,12
+153,14
@@
public abstract class Forest<T> implements GraphViz.ToGraphViz {
private void touched() {
if (touched) return;
touched = true;
private void touched() {
if (touched) return;
touched = true;
+ /*
FastSet<Forest<T>> f2 = new FastSet<Forest<T>>();
for(Forest f : hp)
if (f instanceof Forest.One) f2.add(f);
else for(Forest ff : ((Forest.Many<T>)f))
f2.add(ff);
hp = f2;
FastSet<Forest<T>> f2 = new FastSet<Forest<T>>();
for(Forest f : hp)
if (f instanceof Forest.One) f2.add(f);
else for(Forest ff : ((Forest.Many<T>)f))
f2.add(ff);
hp = f2;
+ */
}
public boolean contains(Forest f) {
touched();
}
public boolean contains(Forest f) {
touched();
@@
-183,7
+178,7
@@
public abstract class Forest<T> implements GraphViz.ToGraphViz {
return true;
}
return true;
}
- public void expand(HashSet<Tree<T>> ht, HashSet<Forest<T>> ignore, Tree<T> bogus) {
+ void expand(HashSet<Tree<T>> ht, HashSet<Forest<T>> ignore, Tree<T> bogus) {
touched();
if (ignore.contains(this)) { ht.add(bogus); return; }
for (Forest<T> f : hp) f.expand(ht, ignore, bogus);
touched();
if (ignore.contains(this)) { ht.add(bogus); return; }
for (Forest<T> f : hp) f.expand(ht, ignore, bogus);