checkpoint
authoradam <adam@megacz.com>
Wed, 14 Dec 2005 06:22:43 +0000 (01:22 -0500)
committeradam <adam@megacz.com>
Wed, 14 Dec 2005 06:22:43 +0000 (01:22 -0500)
darcs-hash:20051214062243-5007d-0826eebcdc822f7fccf8f1e9539904789ddd88f7.gz

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

index d51afed..1c563e8 100644 (file)
@@ -35,11 +35,11 @@ public class MetaGrammar extends ReflectiveWalker {
     public Element     _rightparen_(Object e)                                         { return SELF; }
 
     public PreSequence _amp_(PreSequence p, Object[] o) {
-        p.needs.add(new PreSequence(o, null, true));
+        p.needs.add(new PreSequence(o, null, true).buildSequence(null, true, false));
         return p;
     }
     public PreSequence _amp__tilde_(PreSequence p, Object[] o) {
-        p.hates.add(new PreSequence(o, null, true));
+        p.hates.add(new PreSequence(o, null, true).buildSequence(null, true, false));
         return p;
     }
 
@@ -157,10 +157,9 @@ public class MetaGrammar extends ReflectiveWalker {
             if (s[i]==null) continue;
             HashSet<Sequence> temp = new HashSet<Sequence>();
             for(PreSequence pre : s[i]) {
-                pre.hatess.addAll(seqs);
+                pre.hates.addAll(seqs);
                 Sequence seq = pre.buildSequence(n, false, dropAll);
                 temp.add(seq);
-                //for(Sequence dom : seqs) seq.hates.add(dom);
                 n.add(seq);
             }
             seqs.addAll(temp);
@@ -203,9 +202,8 @@ public class MetaGrammar extends ReflectiveWalker {
     }
 
     public static class PreSequence {
-        public final HashSet<PreSequence> needs  = new HashSet<PreSequence>();
-        public final HashSet<PreSequence> hates  = new HashSet<PreSequence>();
-        public final HashSet<Sequence> hatess = new HashSet<Sequence>();
+        public final HashSet<Sequence> needs  = new HashSet<Sequence>();
+        public final HashSet<Sequence> hates  = new HashSet<Sequence>();
         public /*final*/ String tag;
         public final Object[] o;
         public final boolean keeper;
@@ -241,21 +239,10 @@ public class MetaGrammar extends ReflectiveWalker {
         }
         public Sequence buildSequence(Union u) { return buildSequence(u, false, false); }
         public Sequence buildSequence(Union u, boolean lame, boolean dropAll) {
-
-            HashSet<Sequence> and = new HashSet<Sequence>();
-            HashSet<Sequence> not = new HashSet<Sequence>();
-            for(PreSequence p : needs) {
-                Sequence ps = p.buildSequence(u, true, dropAll);
-                u.add(ps);
-                and.add(ps);
-            }
-            for(Sequence p : hatess) not.add(p);
-            for(PreSequence p : hates) {
-                Sequence ps = p.buildSequence(u, true, dropAll);
-                u.add(ps);
-                not.add(ps);
-            }
-
+            HashSet<Sequence> and = needs;
+            HashSet<Sequence> not = hates;
+            for(Sequence s : and) u.add(s);
+            for(Sequence s : not) u.add(s);
             HashSet<Sequence> set = new HashSet<Sequence>();
             Element[] expansion = expand(u, set);
             boolean keeper = this.keeper;
@@ -322,30 +309,6 @@ public class MetaGrammar extends ReflectiveWalker {
 
     public static final Tree meta =
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
         // DO NOT EDIT STUFF BELOW: IT IS AUTOMATICALLY GENERATED
 new Tree(null, "gram", new Tree[] { new Tree(null, null, new Tree[] { }),
         new Tree(null, "grammar", new Tree[] { new Tree(null, null, new Tree[] { new Tree(null, "::=", new Tree[] { new Tree(null, null, new Tree[] { new Tree(null, "s", new Tree[] { })}),