checkpoint
authoradam <adam@megacz.com>
Fri, 21 Jul 2006 02:58:47 +0000 (22:58 -0400)
committeradam <adam@megacz.com>
Fri, 21 Jul 2006 02:58:47 +0000 (22:58 -0400)
darcs-hash:20060721025847-5007d-4af21fe583fa46436d8d01e817c5ddc02b5e4b9d.gz

TODO
src/edu/berkeley/sbp/Atom.java
src/edu/berkeley/sbp/Forest.java
src/edu/berkeley/sbp/chr/CharAtom.java
src/edu/berkeley/sbp/chr/CharParser.java

diff --git a/TODO b/TODO
index 5522eab..cef631b 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,9 +1,8 @@
 _____________________________________________________________________________
 Immediately
 
-  - Topology crap is kinda messed up
-      - Atom should be a topology, shouldn't it?
-
+  - Sequence shouldn't be an Element
+  - More topology untangling
   - needs/hates/follow API ugliness
 
   - do Forest/Tree still need a Region?
index 0a8ad12..fd91496 100644 (file)
@@ -10,16 +10,21 @@ import edu.berkeley.sbp.*;
 /**
  *  <font color=green>an element which matches some set of one-token-long input strings</font>.
  *
- *  This class is a topology over itself so that Atoms can be
- *  intersected and unioned with each other to result in other
- *  Atom<T>'s (rather than raw Topology<T>'s, which are not Elements).
- *  If you want the latter, use the getTokenTopology() method.
+ *  <p>
+ *  This class is a topology over itself (yes, that's sort of Frege'd
+ *  up) so that Atoms can be intersected and unioned with each other
+ *  to result in other Atom<T>'s (rather than raw Topology<T>'s, which
+ *  are not Elements).  If you want the latter, use the
+ *  getTokenTopology() method.
+ *  </p>
  */
 public abstract class Atom<T> extends Element implements Topology<Atom<T>> {
 
     /** the set (topology) of tokens that can match this element */
     public abstract Topology<T>  getTokenTopology();
 
-    public abstract StringBuffer toString(StringBuffer sb);
+    StringBuffer toString(StringBuffer sb) { sb.append(this); return sb; }
+
 }
 
+
index cdf8a8b..4d8b34f 100644 (file)
@@ -20,11 +20,14 @@ public abstract class Forest<T> implements GraphViz.ToGraphViz {
     /** expand this forest into a set of trees */
     public void expand(HashSet<Tree<T>> ht) { expand(ht, new HashSet<Forest<T>>(), null); }
 
-    /** create a new forest */
-    public static <T> Forest<T> create(Input.Region loc, T head, Forest<T>[] children, boolean lift) {
+    static <T> Forest<T> create(Input.Region loc, T head, Forest<T>[] children, boolean lift) {
         return new One<T>(loc, head, children, lift);
     }
 
+    /** create a new forest */
+    public static <T> Forest<T> create(Input.Region loc, T head, Forest<T>[] children) {
+        return Forest.create(loc, head, children, false); }
+
     // Package-Private //////////////////////////////////////////////////////////////////////////////
 
     abstract void expand(HashSet<Tree<T>> ht, HashSet<Forest<T>> ignore, Tree<T> bogus);
index f2f8e62..e0126ab 100644 (file)
@@ -10,8 +10,6 @@ import edu.berkeley.sbp.Input.Location;
 
 public class CharAtom extends Atom<Character> {
 
-    public StringBuffer toString(StringBuffer sb) { sb.append(this); return sb; }
-
     public CharAtom() { this(new CharTopology()); }
     public CharAtom(char a) { this(a,a); }
     public CharAtom(char a, char b) { this(new CharTopology(a, b)); }
index 9bdadbc..9e9a01a 100644 (file)
@@ -19,7 +19,7 @@ public class CharParser extends Parser<Character,String> {
 
     public Forest<String> shiftToken(Character ct, Location newloc) {
         if (oldloc==null) oldloc = newloc;
-        Forest<String> ret = Forest.create(oldloc.createRegion(newloc), ct.toString(), null, false);
+        Forest<String> ret = Forest.create(oldloc.createRegion(newloc), ct.toString(), null);
         oldloc = newloc;
         return ret;
     }