From: adam Date: Wed, 14 Dec 2005 06:22:43 +0000 (-0500) Subject: checkpoint X-Git-Tag: tag_for_25-Mar~555 X-Git-Url: http://git.megacz.com/?p=sbp.git;a=commitdiff_plain;h=96f3b65f99a63e97b2a9345e00b12aeab01d9548;ds=sidebyside checkpoint darcs-hash:20051214062243-5007d-0826eebcdc822f7fccf8f1e9539904789ddd88f7.gz --- diff --git a/src/edu/berkeley/sbp/misc/MetaGrammar.java b/src/edu/berkeley/sbp/misc/MetaGrammar.java index d51afed..1c563e8 100644 --- a/src/edu/berkeley/sbp/misc/MetaGrammar.java +++ b/src/edu/berkeley/sbp/misc/MetaGrammar.java @@ -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 temp = new HashSet(); 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 needs = new HashSet(); - public final HashSet hates = new HashSet(); - public final HashSet hatess = new HashSet(); + public final HashSet needs = new HashSet(); + public final HashSet hates = new HashSet(); 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 and = new HashSet(); - HashSet not = new HashSet(); - 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 and = needs; + HashSet not = hates; + for(Sequence s : and) u.add(s); + for(Sequence s : not) u.add(s); HashSet set = new HashSet(); 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[] { })}),