checkpoint
[sbp.git] / src / edu / berkeley / sbp / misc / MetaGrammar.java
index f628813..e4592a8 100644 (file)
@@ -258,17 +258,10 @@ public class MetaGrammar extends StringWalker {
             }
             Element[] expansion = o2;
             Sequence ret = null;
-            if (dropAll || lame) {
-                ret = Sequence.drop(expansion, lame);
-                for(Sequence s : and) ret = ret.and(s);
-                for(Sequence s : not) ret = ret.not(s);
-            }
-            else if (unwrap)    ret = new Sequence.Unwrap(expansion, drops, and, not);
-            else if (tag!=null) {
-                ret = Sequence.rewritingSequence(tag, expansion, drops);
-                for(Sequence s : and) ret = ret.and(s);
-                for(Sequence s : not) ret = ret.not(s);
-            } else {
+            if (dropAll || lame) ret = Sequence.drop(expansion, lame);
+            else if (unwrap)    ret = new Sequence.Unwrap(expansion, drops);
+            else if (tag!=null) ret = Sequence.rewritingSequence(tag, expansion, drops);
+            else {
                 int idx = -1;
                 for(int i=0; i<expansion.length; i++)
                     if (!drops[i])
@@ -276,9 +269,9 @@ public class MetaGrammar extends StringWalker {
                         else throw new Error("multiple non-dropped elements in sequence: " + Sequence.drop(expansion,false));
                 if (idx != -1) ret = Sequence.singleton(expansion, idx);
                 else           ret = Sequence.drop(expansion, false);
-                for(Sequence s : and) ret = ret.and(s);
-                for(Sequence s : not) ret = ret.not(s);
             }
+            for(Sequence s : and) ret = ret.and(s);
+            for(Sequence s : not) ret = ret.not(s);
             set.add(ret);
             if (this.noFollow != null) ret.noFollow = new Atom.Invert(new Atom.Infer(this.noFollow));
             return ret;