checkpoint
authoradam <adam@megacz.com>
Mon, 19 Dec 2005 06:13:48 +0000 (01:13 -0500)
committeradam <adam@megacz.com>
Mon, 19 Dec 2005 06:13:48 +0000 (01:13 -0500)
darcs-hash:20051219061348-5007d-4a9701b4285fb460e3fe5ec76a9cff160128cfc5.gz

TODO
src/edu/berkeley/sbp/Union.java
src/edu/berkeley/sbp/misc/CharToken.java
src/edu/berkeley/sbp/misc/MetaGrammar.java
src/edu/berkeley/sbp/tib/Tib.java

diff --git a/TODO b/TODO
index a151061..1dc0b33 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,6 +1,8 @@
 _____________________________________________________________________________
 Immediately
 
+  - simplify metagrammar => go to top-down rewriting => finalize metagrammar and rdp-op's
+
   - What is our use model?
     - Parse, attribute, unify       (ag)
     - Parse, transform tree, walk   (rdp)
index 7370a68..1d4841f 100644 (file)
@@ -36,6 +36,9 @@ public class Union extends Element implements Iterable<Sequence> {
         this.synthetic = synthetic;
     }
 
+    public static Union epsilon = new Union("()");
+    static { epsilon.add(Sequence.empty); }
+
     private Forest.Ref epsilonForm = null;
     Forest epsilonForm() {
         if (epsilonForm != null) return epsilonForm;
index 72578dc..02c67e9 100644 (file)
@@ -63,7 +63,7 @@ public class CharToken implements Token, IntegerTopology.IntegerMappable {
 
     /** returns an element which exactly matches the string given */
     public static Element string(String s) {
-        if (s.length() == 0) return MetaGrammar.epsilon;
+        if (s.length() == 0) return Union.epsilon;
         final String escapified = "\""+StringUtil.escapify(s, "\"\r\n\\")+"\"";
         Element ret;
         if (s.length() == 1) {
index d5a70b3..a62c9a1 100644 (file)
@@ -22,9 +22,6 @@ public class MetaGrammar extends ReflectiveWalker {
 
     private static final Union SELF = new Union("()");
 
-    public static Union epsilon = new Union("()");
-    static { epsilon.add(Sequence.empty); }
-
     ////////////////////////////////////////////////////////////////////////////////
 
     private Union g;
@@ -58,11 +55,11 @@ public class MetaGrammar extends ReflectiveWalker {
     public PreSequence _amp_(PreSequence p, Object[] o)        { return p.and(new PreSequence(o, null).buildSequence(null, true, false, true)); }
     public PreSequence _amp__tilde_(PreSequence p, Object[] o) { return p.not(new PreSequence(o, null).buildSequence(null, true, false, true)); }
     public Object      _star_(Element r)                                              { return Repeat.many0(r); }
-    public Element     epsilon(Object o, Object b)                                    { return epsilon; }
+    public Element     epsilon(Object o, Object b)                                    { return Union.epsilon; }
+    public Object      _leftparen__rightparen_(Object o)                              { return Union.epsilon; }
     public Element     _rightparen_(Object e)                                         { return SELF; }
     public Element     _bang_(Element r)                                              { return r; }
     public Object      _caret_(String s)                                              { return new MyLift(s); }
-    public Object      _leftparen__rightparen_(Object o)                              { return epsilon; }
     public Union       nonTerminal(String s)                                          { return nonTerminal(s, null, false, false); }
     public Union       _colon__colon__equals_(String s, PreSequence[][] p)            { return nonTerminal(s, p, false, false); }
     public Union       _bang__colon__colon__equals_(String s, PreSequence[][] p)      { return nonTerminal(s, p, false, true); }
index 915158b..7f9b913 100644 (file)
@@ -21,9 +21,7 @@ import java.io.*;
  *
  *   This was written as an ad-hoc parser to facilitate
  *   experimentation with the TIB spec.  Once the spec is finalized it
- *   should probably be rewritten using a parser-generator, if
- *   possible (it is unclear whether or not the associated grammar is
- *   context-free).
+ *   should probably be rewritten.
  */
 public class Tib implements Token.Stream<CharToken> {
 
@@ -129,7 +127,7 @@ public class Tib implements Token.Stream<CharToken> {
         }
     }
 
-    public static class Block /*implements Token*/ {
+    public static class Block {
                       Block  parent;
         public  final int    row;
         public  final int    col;
@@ -137,7 +135,6 @@ public class Tib implements Token.Stream<CharToken> {
         private final Vector children = new Vector();
         private       String pending  = "";
 
-        //public Location getLocation() { return /*new Location.Cartesian(row, col)*/null; }
         public int    size() { return children.size(); }
         public Object child(int i) { return children.elementAt(i); }
         public boolean isLiteral() {  return false; }