checkpoint
[sbp.git] / src / edu / berkeley / sbp / Repeat.java
index 2dd3928..c4e9486 100644 (file)
@@ -10,9 +10,10 @@ import java.lang.ref.*;
 /** currently this class exports only static methods to create repetitions; there are no public instance methods or constructors */
 /* FIXME make private again */ public class Repeat extends Union {
 
-    public Repeat(final Element e, boolean zeroOkay, boolean manyOkay, final Element separator, boolean maximal) {
-        this(e, zeroOkay, manyOkay, separator, maximal, null); }
-    Repeat(final Element e, boolean zeroOkay, boolean manyOkay, final Element separator, boolean maximal, Object tag) {
+    public Repeat(final Element e, boolean zeroOkay, boolean manyOkay, final Element separator, Object tag) {
+        this(e, zeroOkay, manyOkay, separator, false, tag);
+    }
+    protected Repeat(final Element e, boolean zeroOkay, boolean manyOkay, final Element separator, boolean maximal, Object tag) {
         super(e+(!manyOkay ? "?" : (zeroOkay ? (maximal ? "**" : "*") : (maximal ? "++" : "+")))+(separator==null?"":("/"+separator)), true);
         if (maximal && zeroOkay && separator != null)
             throw new RuntimeException("cannot create a maximal repetition of zero or more items with a separator (yet): " + this);
@@ -32,4 +33,11 @@ import java.lang.ref.*;
             for(Sequence s : this)
                 s.follow = new edu.berkeley.sbp.misc.MetaGrammar.Invert(new edu.berkeley.sbp.misc.MetaGrammar.Infer(separator==null ? e : separator));
     }
+
+    public static class Maximal extends Repeat {
+        public Maximal(final Element e, boolean zeroOkay, boolean manyOkay, final Element separator, Object tag) {
+            super(e, zeroOkay, manyOkay, separator, true, tag);
+        }
+    }
+
 }