X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FRepeat.java;fp=src%2Fedu%2Fberkeley%2Fsbp%2FRepeat.java;h=c4e948627cf8903076ed3feb85796abf7dad5714;hp=2dd39286674c447357796f446e76f14577fdb00a;hb=74fc87dc827975ed4e9e411bb169a5f5bfb1010f;hpb=7d1d5b9e2969e687cc07592f5a212681f8d26479 diff --git a/src/edu/berkeley/sbp/Repeat.java b/src/edu/berkeley/sbp/Repeat.java index 2dd3928..c4e9486 100644 --- a/src/edu/berkeley/sbp/Repeat.java +++ b/src/edu/berkeley/sbp/Repeat.java @@ -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); + } + } + }