From e214b29e31c1b1594695925eefc1fad411ce7081 Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 15 Jan 2006 16:31:34 -0500 Subject: [PATCH] checkpoint darcs-hash:20060115213134-5007d-5cc1fb1af596fd9cc8ab18f5ccac2128c0403912.gz --- src/edu/berkeley/sbp/Sequence.java | 2 +- src/edu/berkeley/sbp/misc/MetaGrammar.java | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/edu/berkeley/sbp/Sequence.java b/src/edu/berkeley/sbp/Sequence.java index 68e311e..328550d 100644 --- a/src/edu/berkeley/sbp/Sequence.java +++ b/src/edu/berkeley/sbp/Sequence.java @@ -22,7 +22,7 @@ public abstract class Sequence extends Element implements Iterable { public static final Sequence empty = new Sequence.Constant.Empty(); /** after matching the sequence, do not add anything to the output tree */ - public static Sequence drop(Element[] e, HashSet and, HashSet not, boolean lame) { return new Constant.Drop(e, and, not, lame); } + public static Sequence drop(Element[] e, boolean lame) { return new Constant.Drop(e, null, null, lame); } /** after matching the sequence, insert a constant into the output tree */ public static Sequence constant(Element[] e, Object o, HashSet and, HashSet not) { return new Constant(e, o, and, not); } diff --git a/src/edu/berkeley/sbp/misc/MetaGrammar.java b/src/edu/berkeley/sbp/misc/MetaGrammar.java index 4348dec..b1a3e8c 100644 --- a/src/edu/berkeley/sbp/misc/MetaGrammar.java +++ b/src/edu/berkeley/sbp/misc/MetaGrammar.java @@ -258,7 +258,11 @@ public class MetaGrammar extends StringWalker { } Element[] expansion = o2; Sequence ret = null; - if (dropAll || lame) ret = Sequence.drop(expansion, and, not, lame); + 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, and, not); else { @@ -266,9 +270,13 @@ public class MetaGrammar extends StringWalker { for(int i=0; i