_____________________________________________________________________________
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?
/**
* <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; }
+
}
+
/** 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);
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)); }
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;
}