checkpoint
authoradam <adam@megacz.com>
Sat, 22 Jul 2006 22:59:18 +0000 (18:59 -0400)
committeradam <adam@megacz.com>
Sat, 22 Jul 2006 22:59:18 +0000 (18:59 -0400)
darcs-hash:20060722225918-5007d-b7800447e0ef0995b442312c261ebc463ad71f60.gz

TODO
src/edu/berkeley/sbp/Sequence.java
src/edu/berkeley/sbp/Union.java
src/edu/berkeley/sbp/chr/CharAtom.java
src/edu/berkeley/sbp/meta/MetaGrammarBindings.java

diff --git a/TODO b/TODO
index 23b23d2..cecd2d4 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,28 +1,28 @@
 _____________________________________________________________________________
 Immediately
 
 _____________________________________________________________________________
 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<T> really be type-parameterized?
+  - Sequence extends Element (?) -> then add Union.add(element)
+  - Parameterize Sequence/Union/Atom <Tok,Result>
+  - Make sure we never use raw types
   - do Forest/Tree still need a Region?
 
   - 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?
 
   - grammar highlighting?
-  - comment indentation vs block indentation?
-  - { and } in <pre>
-  - 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)
   - 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
 
 
 ______________________________________________________________________________
 
 
 ______________________________________________________________________________
index 2530a21..f431518 100644 (file)
@@ -39,25 +39,25 @@ public abstract class Sequence extends Element implements Iterable<Element> {
     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) { 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 e      the elements to match
-     *  @param drops  only elements of <tt>e</tt> whose corresponding <tt>boolean</tt> in <tt>drops</tt>
+     *  @param drop   only elements of <tt>e</tt> whose corresponding <tt>boolean</tt> in <tt>drops</tt>
      *                is <i>false</i> will be included in the output tree
      *                is <i>false</i> 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);
     }
 
     ////////////////////////////////////////////////////////////////////////////////
     }
 
     ////////////////////////////////////////////////////////////////////////////////
index 204404d..77a1581 100644 (file)
@@ -44,6 +44,7 @@ public class Union extends Element implements Iterable<Sequence> {
         return alternatives.contains(s);
     }
 
         return alternatives.contains(s);
     }
 
+    /** iterator over this Union's Sequences */
     public Iterator<Sequence> iterator() {
         viewed = true;
         return alternatives.iterator();
     public Iterator<Sequence> iterator() {
         viewed = true;
         return alternatives.iterator();
index cb1ed80..1d76aa7 100644 (file)
@@ -43,7 +43,7 @@ public class CharAtom extends Atom<Character> {
                     public String toString() { return escapified; } };
             Element[] refs = new Element[s.length()];
             for(int i=0; i<refs.length; i++) refs[i] = new CharAtom(s.charAt(i));
                     public String toString() { return escapified; } };
             Element[] refs = new Element[s.length()];
             for(int i=0; i<refs.length; i++) refs[i] = new CharAtom(s.charAt(i));
-            ret2.add(Sequence.newConstantSequence(refs, s));
+            ret2.add(Sequence.create(refs, s));
             ret = ret2;
         }
         return ret;
             ret = ret2;
         }
         return ret;
index 7a18bab..9232d5c 100644 (file)
@@ -246,9 +246,9 @@ public class MetaGrammarBindings extends AnnotationGrammarBindings {
                 for(int i=0; i<els.length; i++)
                     if (!drops[i])
                         if (idx==-1) idx = i;
                 for(int i=0; i<els.length; i++)
                     if (!drops[i])
                         if (idx==-1) idx = i;
-                        else throw new Error("multiple non-dropped elements in sequence: " + Sequence.newConstantSequence(els, null));
+                        else throw new Error("multiple non-dropped elements in sequence: " + Sequence.create(els, null));
                 if (idx != -1) ret = Sequence.create(els, idx);
                 if (idx != -1) ret = Sequence.create(els, idx);
-                else           ret = Sequence.newConstantSequence(els, null);
+                else           ret = Sequence.create(els, null);
             }
             if (this.follow != null)
                 ret = ret.followedBy(this.follow.toAtom(cx));
             }
             if (this.follow != null)
                 ret = ret.followedBy(this.follow.toAtom(cx));