From dc46168f73937268a2a08577e4271d133a91bbef Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 27 May 2007 16:21:36 -0400 Subject: [PATCH] cleanup of Repeat.java darcs-hash:20070527202136-5007d-e877e0f8a62f106813d71c18288b8042f466138b.gz --- src/edu/berkeley/sbp/meta/Repeat.java | 52 ++++++++++++++------------------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/src/edu/berkeley/sbp/meta/Repeat.java b/src/edu/berkeley/sbp/meta/Repeat.java index a8739d9..bbf800a 100644 --- a/src/edu/berkeley/sbp/meta/Repeat.java +++ b/src/edu/berkeley/sbp/meta/Repeat.java @@ -1,4 +1,4 @@ -// Copyright 2006 all rights reserved; see LICENSE file for BSD-style license +// Copyright 2007 all rights reserved; see LICENSE file for BSD-style license package edu.berkeley.sbp.meta; import edu.berkeley.sbp.util.*; @@ -8,7 +8,10 @@ import java.util.*; import java.lang.reflect.*; import java.lang.ref.*; -/** currently this class exports only static methods to create repetitions; there are no public instance methods or constructors */ +/** + * Currently this class exports only static methods to create repetitions; + * there are no public instance methods or constructors + */ public class Repeat extends Union { public Repeat(final Element e, boolean zeroOkay, boolean manyOkay, Object tag) { @@ -29,40 +32,29 @@ public class Repeat extends Union { : ("/"+separator)), true); if (follow != null) { - Sequence s = Sequence.create(new Repeat(e, zeroOkay, manyOkay, separator, maximal, tag, null)).followedBy(follow); + Sequence s = Sequence.create(new Repeat(e, zeroOkay, manyOkay, + separator, maximal, tag, null)).followedBy(follow); add(s); return; } - if (zeroOkay && !manyOkay) { - // FIXME - add(Sequence.create(tag, new Element[] { }, null, false).followedBy(follow)); - add(Sequence.create(tag, new Element[] { e }, null, false).followedBy(follow)); - } else if (zeroOkay) { - add(Sequence.create(tag, new Element[] { }, null, false).followedBy(follow)); - //add(new Sequence.Constant.Empty()); - // FUGLY + if (zeroOkay) + add(Sequence.create(tag, new Element[] { }, null).followedBy(follow)); + if (!(zeroOkay && manyOkay)) + add(Sequence.create(tag, new Element[] { e }, null).followedBy(follow)); + if (zeroOkay && manyOkay) add(Sequence.create(many1(e, separator, tag)).followedBy(follow)); - } else { - add(Sequence.create(tag, new Element[] { e }, null, false).followedBy(follow)); - /* + if (!zeroOkay && manyOkay) { if (separator==null) - add(Sequence.create(tag, new Element[] { e, Repeat.this }, new boolean[] { false, false }, true).followedBy(follow)); + add(Sequence.create(tag, + new Element[] { Repeat.this, e }, + new boolean[] { false, false }, + new boolean[] { true, false })); else - add(Sequence.create(tag, new Element[] { e, separator, Repeat.this }, new boolean[] { false, true, false }, true).followedBy(follow)); - */ - if (separator==null) - /* - add(Sequence.create(tag, new Element[] { e, Repeat.this }, new boolean[] { false, false }, true).followedBy(follow)); - */ - add(Sequence.createLeft(tag, new Element[] { Repeat.this, e }, - new boolean[] { false, false }, true)); - else { - /* - add(Sequence.create(tag, new Element[] { e, separator, Repeat.this }, new boolean[] { false, true, false }, true).followedBy(follow)); - */ - add(Sequence.createLeft(tag, new Element[] { Repeat.this, separator, e }, - new boolean[] { false, true, false }, true)); - } + add(Sequence.create(tag, + new Element[] { Repeat.this, separator, e }, + new boolean[] { false, true, false }, + new boolean[] { true, false, false } + )); } } -- 1.7.10.4