From 75d0fa39d405292f4b831a6d1743f2aeea01ebd4 Mon Sep 17 00:00:00 2001 From: adam Date: Sat, 22 Jul 2006 18:59:18 -0400 Subject: [PATCH] checkpoint darcs-hash:20060722225918-5007d-b7800447e0ef0995b442312c261ebc463ad71f60.gz --- TODO | 26 ++++++++++---------- src/edu/berkeley/sbp/Sequence.java | 26 ++++++++++---------- src/edu/berkeley/sbp/Union.java | 1 + src/edu/berkeley/sbp/chr/CharAtom.java | 2 +- src/edu/berkeley/sbp/meta/MetaGrammarBindings.java | 4 +-- 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/TODO b/TODO index 23b23d2..cecd2d4 100644 --- a/TODO +++ b/TODO @@ -1,28 +1,28 @@ _____________________________________________________________________________ Immediately - - The repeat API's in Sequence are ugly - - segregate the sequence static-constructors? - - - Sequence shouldn't be an Element -> make Union.add(Element) - - Should Tree really be type-parameterized? + - Sequence extends Element (?) -> then add Union.add(element) + - Parameterize Sequence/Union/Atom + - Make sure we never use raw types - do Forest/Tree still need a Region? - - reconsider the degree of genericization + - More topology untangling + + - tib: use the lexer only for indentation increases/decreases - grammar highlighting? - - comment indentation vs block indentation? - - { and } in
-  - recursive { { foo } }
 
-  - More topology untangling
+  - copyright notices
+
+  - tutorial
+
+______________________________________________________________________________
+v1.1
+
   - Forest needs a "manual access" API
       - 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
-  - copyright notices
-  - documentation
 
 
 ______________________________________________________________________________
diff --git a/src/edu/berkeley/sbp/Sequence.java b/src/edu/berkeley/sbp/Sequence.java
index 2530a21..f431518 100644
--- a/src/edu/berkeley/sbp/Sequence.java
+++ b/src/edu/berkeley/sbp/Sequence.java
@@ -39,25 +39,25 @@ public abstract class Sequence extends Element implements Iterable {
     public static Sequence create(Element e) { return create(new Element[] { e }, 0); }
 
     /** create a sequence which drops the result of all but one of its element */
-    public static Sequence create(Element[] e, int idx) { return new Singleton(e, idx); }
-
-    /** after matching the sequence, insert a constant into the output tree */
-    public static Sequence newConstantSequence(Element[] e, Object o) { return new Constant(e, o); }
+    public static Sequence create(Element[] e, int which) { return new Singleton(e, which); }
 
+    /** create a sequence which always evaluates to a constant result  */
+    public static Sequence create(Element[] e, Object result) { return new Constant(e, result); }
 
     /**
-     *  after matching the sequence, create the specified output tree
-     *  @param tag    the tag for the output tree
+     *  create a sequence (general form)
+     *  @param head   the head of the output tree
      *  @param e      the elements to match
-     *  @param drops  only elements of e whose corresponding boolean in drops
+     *  @param drop   only elements of e whose corresponding boolean in drops
      *                is false will be included in the output tree
-     *  @param unwrap if true, all children of the last child (ie
-     *                grandchildren) are promoted to children of this node; this is very useful for matching repetitions
+     *  @param foster if true, all children of the last child (ie
+     *                grandchildren) are promoted to children of this
+     *                node; this is very useful for matching repetitions
      **/
-    public static Sequence create(Object tag, Element[] e, boolean[] drops, boolean unwrap) {
-        return unwrap
-            ? new Unwrap(e, tag, drops)
-            : new RewritingSequence(tag, e, drops);
+    public static Sequence create(Object head, Element[] e, boolean[] drop, boolean foster) {
+        return foster
+            ? new Unwrap(e, head, drop)
+            : new RewritingSequence(head, e, drop);
     }
 
     ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/edu/berkeley/sbp/Union.java b/src/edu/berkeley/sbp/Union.java
index 204404d..77a1581 100644
--- a/src/edu/berkeley/sbp/Union.java
+++ b/src/edu/berkeley/sbp/Union.java
@@ -44,6 +44,7 @@ public class Union extends Element implements Iterable {
         return alternatives.contains(s);
     }
 
+    /** iterator over this Union's Sequences */
     public Iterator iterator() {
         viewed = true;
         return alternatives.iterator();
diff --git a/src/edu/berkeley/sbp/chr/CharAtom.java b/src/edu/berkeley/sbp/chr/CharAtom.java
index cb1ed80..1d76aa7 100644
--- a/src/edu/berkeley/sbp/chr/CharAtom.java
+++ b/src/edu/berkeley/sbp/chr/CharAtom.java
@@ -43,7 +43,7 @@ public class CharAtom extends Atom {
                     public String toString() { return escapified; } };
             Element[] refs = new Element[s.length()];
             for(int i=0; i