add first-class zero-or-more repetitions
[sbp.git] / src / edu / berkeley / sbp / meta / Repeat.java
index a97eb38..800639b 100644 (file)
@@ -41,9 +41,12 @@ class Repeat extends Union {
             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)
+
+        // FEATURE: stringify ~[]* as ...
+        if (zeroOkay && manyOkay && separator!=null) {
             add(Sequence.create(many1(e, separator, tag)).followedBy(follow));
-        if (!zeroOkay && manyOkay) {
+
+        } else if (manyOkay) {
             if (separator==null)
                 add(Sequence.create(tag,
                                     new Element[] { Repeat.this,    e },