checkpoint
authoradam <adam@megacz.com>
Wed, 14 Dec 2005 07:03:06 +0000 (02:03 -0500)
committeradam <adam@megacz.com>
Wed, 14 Dec 2005 07:03:06 +0000 (02:03 -0500)
darcs-hash:20051214070306-5007d-1310612845226909a0e13346a978fafe52eee3f9.gz

src/edu/berkeley/sbp/misc/MetaGrammar.java
tests/meta.g

index d160680..900ee3f 100644 (file)
@@ -25,9 +25,30 @@ public class MetaGrammar extends ReflectiveWalker {
     public static Union epsilon = new Union("()");
     static { epsilon.add(Sequence.empty); }
 
+    ////////////////////////////////////////////////////////////////////////////////
+
+    private Union g;
+    private HashMap<String,Union> nt;
+    private int anon = 0;
+    private Element dws;
+    private String startSymbol;
+
+    public MetaGrammar() { this("s"); }
+    public MetaGrammar(String s) { done(s); }
+    public Union done() { return done("s"); }
+    public Union done(String str) {
+        Union ret = g;
+        g = new Union(str);
+        startSymbol = str;
+        nt = new HashMap<String,Union>();
+        dropAll = new HashSet<Element>();
+        nt.put(str, g);
+        this.dws = Repeat.maximal(Repeat.many0(nonTerminal("w")));
+        return ret;
+    }
     // MetaGrammar //////////////////////////////////////////////////////////////////////////////
 
-    public PreSequence _equals__greater_(Object[] o, String s) { return new PreSequence(o, s); }
+    public PreSequence _equals__greater_(Object[] o, String s)                        { return new PreSequence(o, s); }
     public Object      _star_(Element r)                                              { return Repeat.many0(r); }
     public Element     epsilon(Object o, Object b)                                    { return epsilon; }
     public Element     _rightparen_(Object e)                                         { return SELF; }
@@ -104,40 +125,16 @@ public class MetaGrammar extends ReflectiveWalker {
         return CharToken.set(ret);
     }
 
+    public PreSequence wrap(Object[] o)    { return new PreSequence(o, ""); }
+    public PreSequence rewrite(Object[] o) { return new PreSequence(o, null); }
 
-    ////////////////////////////////////////////////////////////////////////////////
-
-    private Union g;
-    private HashMap<String,Union> nt;
-    private int anon = 0;
-    private Element dws;
-    private String startSymbol;
-
-    public MetaGrammar() { this("s"); }
-    public MetaGrammar(String s) { done(s); }
-    public Union done() { return done("s"); }
-    public Union done(String str) {
-        Union ret = g;
-        g = new Union(str);
-        startSymbol = str;
-        nt = new HashMap<String,Union>();
-        dropAll = new HashSet<Element>();
-        nt.put(str, g);
-        this.dws = Repeat.maximal(Repeat.many0(nonTerminal("w")));
-        return ret;
+    public static class MyLift {
+        public final String s;
+        public MyLift(String s) { this.s = s; }
     }
-
-    public PreSequence sequence(Object[] o) { return new PreSequence(o, null); }
-
-
-    public PreSequence wrap(Object[] o) { return new PreSequence(o, ""); }
-    public PreSequence mwrap(Object[] o) { return new PreSequence(o, ""); }
-    public PreSequence rewrite(Object[] o) { return new PreSequence(o, null); }
-    public PreSequence rewrite(Object[] o, Object o2) {
-        Object[] o3 = new Object[o.length + 1];
-        System.arraycopy(o, 0, o3, 0, o.length);
-        o3[o3.length-1] = o2;
-        return rewrite(o3);
+    public static class MyDrop {
+        public final Object o;
+        public MyDrop(Object o) { this.o = o; }
     }
 
     public static class PreSequence {
@@ -235,15 +232,6 @@ public class MetaGrammar extends ReflectiveWalker {
         os.close();
     }
 
-    public static class MyLift {
-        public final String s;
-        public MyLift(String s) { this.s = s; }
-    }
-    public static class MyDrop {
-        public final Object o;
-        public MyDrop(Object o) { this.o = o; }
-    }
-
     public static final Tree meta =
 
 
index d05ee8f..7afdbc4 100644 (file)
@@ -20,7 +20,6 @@ conjuncts   ::=  rewrite
 rewrite  ::=  sequence                  /ws        => "rewrite"
            |  sequence ^"=>" word       /ws
            |  sequence ^"=>" quoted     /ws
-           |  sequence  "=>" "()"       /ws        => "wrap"
 
 ec       ::= [~\-\]\\\~]
            | escaped