From: adam Date: Wed, 14 Dec 2005 02:33:59 +0000 (-0500) Subject: checkpoint X-Git-Tag: tag_for_25-Mar~576 X-Git-Url: http://git.megacz.com/?p=sbp.git;a=commitdiff_plain;h=8340e71687098e2505803d674fe31c6c6c380f68 checkpoint darcs-hash:20051214023359-5007d-4e0ae12e81f64a0b9abb7dd423b62823cf48ec22.gz --- diff --git a/src/edu/berkeley/sbp/misc/MetaGrammar.java b/src/edu/berkeley/sbp/misc/MetaGrammar.java index f532009..c513655 100644 --- a/src/edu/berkeley/sbp/misc/MetaGrammar.java +++ b/src/edu/berkeley/sbp/misc/MetaGrammar.java @@ -201,7 +201,7 @@ public class MetaGrammar extends ReflectiveWalker { HashSet temp = new HashSet(); for(PreSequence pre : s[i]) { pre.hatess.addAll(seqs); - Sequence seq = pre.buildSequence(null, n, false, dropAll); + Sequence seq = pre.buildSequence(n, false, dropAll); temp.add(seq); //for(Sequence dom : seqs) seq.hates.add(dom); n.add(seq); @@ -238,15 +238,8 @@ public class MetaGrammar extends ReflectiveWalker { private final boolean maximal; private final boolean zero; public Rep(Element e, Element s, boolean maximal, boolean zero) { this.e = e; this.s = s; this.zero = zero; this.maximal = maximal;} - public Element build(Element ws) { - Element sep = null; - if (ws==null) sep = s; - else if (s==null) sep = ws; - else { - Union ws2 = new Union(e + "/" + s + "/" + ws, true); - ws2.add(Sequence.singleton(new Element[] { ws, s, ws }, 0, null, null)); - sep = ws2; - } + public Element build() { + Element sep = s; Element ret = zero ? Repeat.many0(e, sep) : Repeat.many1(e, sep); return maximal ? Repeat.maximal(ret) : ret; } @@ -263,7 +256,7 @@ public class MetaGrammar extends ReflectiveWalker { public PreSequence(Object[] o, String tag) { this(o, tag, false); } public PreSequence(Object[] o, String tag, boolean keeper) { this.o = o; this.tag = tag; this.keeper = keeper; } boolean[] drops = null; - public Element[] expand(Element ws, Union u, HashSet set) { + public Element[] expand(Union u, HashSet set) { if (o==null) return new Element[0]; Element[] o2 = new Element[o.length]; drops = new boolean[o.length]; @@ -271,11 +264,11 @@ public class MetaGrammar extends ReflectiveWalker { for(int i=0; i and = new HashSet(); HashSet not = new HashSet(); for(PreSequence p : needs) { - Sequence ps = p.buildSequence(ws, u, true, dropAll); + 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(ws, u, true, dropAll); + Sequence ps = p.buildSequence(u, true, dropAll); u.add(ps); not.add(ps); } HashSet set = new HashSet(); - Element[] expansion = expand(ws, u, set); + Element[] expansion = expand(u, set); boolean keeper = this.keeper; Sequence ret = dropAll || lame || keeper ? Sequence.drop(expansion, and, not, lame) : null; if (ret==null && tag!=null) {