/** 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);
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);
+ }
+ }
+
}