checkpoint
authoradam <adam@megacz.com>
Mon, 19 Dec 2005 08:37:48 +0000 (03:37 -0500)
committeradam <adam@megacz.com>
Mon, 19 Dec 2005 08:37:48 +0000 (03:37 -0500)
darcs-hash:20051219083748-5007d-76138ec6afdade920737703e19db2641744e4f94.gz

src/edu/berkeley/sbp/misc/MetaGrammar.java

index f8c40ba..ab359c6 100644 (file)
@@ -51,8 +51,8 @@ public class MetaGrammar extends ReflectiveWalker {
 
     // MetaGrammar //////////////////////////////////////////////////////////////////////////////
 
-    public PreSequence _amp_(PreSequence p, Object[] o)        { return p.and(new PreSequence(o, null).buildSequence(null, true, false, true)); }
-    public PreSequence _amp__tilde_(PreSequence p, Object[] o) { return p.not(new PreSequence(o, null).buildSequence(null, true, false, true)); }
+    public PreSequence _amp_(PreSequence p, Object[] o)        { return p.and(new PreSequence(o, null).buildSequence(null, true, false)); }
+    public PreSequence _amp__tilde_(PreSequence p, Object[] o) { return p.not(new PreSequence(o, null).buildSequence(null, true, false)); }
     public Element     epsilon(Object o, Object b)                                    { return Union.epsilon; }
     public Object      _leftparen__rightparen_(Object o)                              { return Union.epsilon; }
     public Element     _rightparen_(Object e)                                         { return SELF; }
@@ -71,7 +71,7 @@ public class MetaGrammar extends ReflectiveWalker {
             HashSet<Sequence> temp = new HashSet<Sequence>();
             for(PreSequence pre : s[i]) {
                 pre.not.addAll(seqs);
-                Sequence seq = pre.buildSequence(n, false, dropAll, false);
+                Sequence seq = pre.buildSequence(n, false, dropAll);
                 temp.add(seq);
                 n.add(seq);
             }
@@ -193,8 +193,8 @@ public class MetaGrammar extends ReflectiveWalker {
             u.add(buildSequence(u));
             return u;
         }
-        public Sequence buildSequence(Union u) { return buildSequence(u, false, false, false); }
-        public Sequence buildSequence(Union u, boolean lame, boolean dropAll, boolean keeper) {
+        public Sequence buildSequence(Union u) { return buildSequence(u, false, false); }
+        public Sequence buildSequence(Union u, boolean lame, boolean dropAll) {
             for(Sequence s : and) u.add(s);
             for(Sequence s : not) u.add(s);
             HashSet<Sequence> set = new HashSet<Sequence>();
@@ -214,9 +214,10 @@ public class MetaGrammar extends ReflectiveWalker {
                 }
             }
             Element[] expansion = o2;
-            Sequence ret = dropAll || lame || keeper ? Sequence.drop(expansion, and, not, lame) : null;
-            if (ret==null && tag!=null) ret = Sequence.rewritingSequence(tag, expansion, drops, and, not);
-            if (ret==null) {
+            Sequence ret = null;
+            if (dropAll || lame) ret = Sequence.drop(expansion, and, not, lame);
+            else if (tag!=null) ret = Sequence.rewritingSequence(tag, expansion, drops, and, not);
+            else {
                 int idx = -1;
                 for(int i=0; i<expansion.length; i++) {
                     if (!drops[i]) idx = i;