From: adam Date: Fri, 21 Jul 2006 02:58:47 +0000 (-0400) Subject: checkpoint X-Git-Tag: tag_for_25-Mar~107 X-Git-Url: http://git.megacz.com/?p=sbp.git;a=commitdiff_plain;h=2cc11837a52505dd9863bcd366240a8f229af294;hp=d28917b3c84c429e8fd6587717df9e90a894b18f checkpoint darcs-hash:20060721025847-5007d-4af21fe583fa46436d8d01e817c5ddc02b5e4b9d.gz --- diff --git a/TODO b/TODO index 5522eab..cef631b 100644 --- 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? diff --git a/src/edu/berkeley/sbp/Atom.java b/src/edu/berkeley/sbp/Atom.java index 0a8ad12..fd91496 100644 --- a/src/edu/berkeley/sbp/Atom.java +++ b/src/edu/berkeley/sbp/Atom.java @@ -10,16 +10,21 @@ import edu.berkeley.sbp.*; /** * an element which matches some set of one-token-long input strings. * - * This class is a topology over itself so that Atoms can be - * intersected and unioned with each other to result in other - * Atom's (rather than raw Topology's, which are not Elements). - * If you want the latter, use the getTokenTopology() method. + *

+ * 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's (rather than raw Topology's, which + * are not Elements). If you want the latter, use the + * getTokenTopology() method. + *

*/ public abstract class Atom extends Element implements Topology> { /** the set (topology) of tokens that can match this element */ public abstract Topology getTokenTopology(); - public abstract StringBuffer toString(StringBuffer sb); + StringBuffer toString(StringBuffer sb) { sb.append(this); return sb; } + } + diff --git a/src/edu/berkeley/sbp/Forest.java b/src/edu/berkeley/sbp/Forest.java index cdf8a8b..4d8b34f 100644 --- a/src/edu/berkeley/sbp/Forest.java +++ b/src/edu/berkeley/sbp/Forest.java @@ -20,11 +20,14 @@ public abstract class Forest implements GraphViz.ToGraphViz { /** expand this forest into a set of trees */ public void expand(HashSet> ht) { expand(ht, new HashSet>(), null); } - /** create a new forest */ - public static Forest create(Input.Region loc, T head, Forest[] children, boolean lift) { + static Forest create(Input.Region loc, T head, Forest[] children, boolean lift) { return new One(loc, head, children, lift); } + /** create a new forest */ + public static Forest create(Input.Region loc, T head, Forest[] children) { + return Forest.create(loc, head, children, false); } + // Package-Private ////////////////////////////////////////////////////////////////////////////// abstract void expand(HashSet> ht, HashSet> ignore, Tree bogus); diff --git a/src/edu/berkeley/sbp/chr/CharAtom.java b/src/edu/berkeley/sbp/chr/CharAtom.java index f2f8e62..e0126ab 100644 --- a/src/edu/berkeley/sbp/chr/CharAtom.java +++ b/src/edu/berkeley/sbp/chr/CharAtom.java @@ -10,8 +10,6 @@ import edu.berkeley.sbp.Input.Location; public class CharAtom extends Atom { - 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)); } diff --git a/src/edu/berkeley/sbp/chr/CharParser.java b/src/edu/berkeley/sbp/chr/CharParser.java index 9bdadbc..9e9a01a 100644 --- a/src/edu/berkeley/sbp/chr/CharParser.java +++ b/src/edu/berkeley/sbp/chr/CharParser.java @@ -19,7 +19,7 @@ public class CharParser extends Parser { public Forest shiftToken(Character ct, Location newloc) { if (oldloc==null) oldloc = newloc; - Forest ret = Forest.create(oldloc.createRegion(newloc), ct.toString(), null, false); + Forest ret = Forest.create(oldloc.createRegion(newloc), ct.toString(), null); oldloc = newloc; return ret; }