checkpoint
[sbp.git] / src / edu / berkeley / sbp / misc / MetaGrammar.java
index d6e8a88..5ea2de3 100644 (file)
@@ -78,10 +78,14 @@ public class MetaGrammar extends ReflectiveWalker {
         }
         return ret;
     }
-    public Object _plus__slash_(final Element r, Object s) { return rep(r, (Element)s, false, false); }
-    public Object _star__slash_(final Element r, Object s) { return rep(r, (Element)s, false, true); }
-    public Object _star__star_(final Element r) { return rep(r, null, true, true); }
-    public Object _plus__plus_(final Element r) { return rep(r, null, true, false); }
+    public Element rep(Element e, Element sep, boolean maximal, boolean zero) {
+        Element ret = zero ? Repeat.many0(e, sep) :  Repeat.many1(e, sep);
+        return maximal ? Repeat.maximal(ret) : ret;
+    }
+    public Object _plus__slash_(final Element r, Element s) { return Repeat.many1(r, s); }
+    public Object _star__slash_(final Element r, Element s) { return Repeat.many0(r, s); }
+    public Object _star__star_(final Element r) { return Repeat.maximal(Repeat.many0(r)); }
+    public Object _plus__plus_(final Element r) { return Repeat.maximal(Repeat.many1(r)); }
     public Element _question_(final Element r) { return Repeat.maybe(r); }
     public MetaGrammar gram(Object o, MetaGrammar g, Object o2) { return g; }
     public MetaGrammar  grammar(Object[] o) { return this; }
@@ -140,16 +144,6 @@ public class MetaGrammar extends ReflectiveWalker {
         o3[o3.length-1] = o2;
         return rewrite(o3);
     }
-        
-    public static class PreBrace {
-        public final Object[] o;
-        public PreBrace(Object[] o) { this.o = o; }
-    }
-
-    public Element rep(Element e, Element sep, boolean maximal, boolean zero) {
-        Element ret = zero ? Repeat.many0(e, sep) :  Repeat.many1(e, sep);
-        return maximal ? Repeat.maximal(ret) : ret;
-    }
 
     public static class PreSequence {
         public PreSequence not(Sequence s) { not.add(s); return this; }