clean up metagrammar handling of drop and question-mark
[sbp.git] / src / edu / berkeley / sbp / meta / Repeat.java
index b3f1841..25581b2 100644 (file)
@@ -18,13 +18,21 @@ public class Repeat extends Union {
     protected Repeat(final Element e, boolean zeroOkay, boolean manyOkay, final Element separator, boolean maximal, Object tag) {
         this(e, zeroOkay, manyOkay, separator, maximal, tag, null); }
     protected Repeat(final Element e, boolean zeroOkay, boolean manyOkay, final Element separator, boolean maximal, Object tag, Atom follow) {
-        super(e+(!manyOkay ? "?" : (zeroOkay ? (maximal ? "**" : "*") : (maximal ? "++" : "+")))+(separator==null?"":("/"+separator)), true);
+        super(e
+              +(!manyOkay
+                ? "?"
+                : (zeroOkay
+                   ? (maximal ? "**" : "*")
+                   : (maximal ? "++" : "+")))
+              +(separator==null
+                ? ""
+                : ("/"+separator)),
+              true);
         if (zeroOkay && !manyOkay) {
-            add(Sequence.create().followedBy(follow));
-            add(Sequence.create(e).followedBy(follow));
-            return;
-        }
-        if (zeroOkay) {
+            // 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