From 5d3efb18a5ac20129a699102fa0099b98b558874 Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 15 Jan 2006 16:39:25 -0500 Subject: [PATCH] checkpoint darcs-hash:20060115213925-5007d-251fdc1aa64c6dc89bf6ed5ebfe43d656150e5fb.gz --- src/edu/berkeley/sbp/Repeat.java | 4 ++-- src/edu/berkeley/sbp/Sequence.java | 9 +++++---- src/edu/berkeley/sbp/misc/MetaGrammar.java | 19 ++++++------------- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/edu/berkeley/sbp/Repeat.java b/src/edu/berkeley/sbp/Repeat.java index 9b6d6bb..aa91a64 100644 --- a/src/edu/berkeley/sbp/Repeat.java +++ b/src/edu/berkeley/sbp/Repeat.java @@ -41,9 +41,9 @@ public class Repeat extends Union { } else { add(new Sequence.RewritingSequence(null, new Element[] { e }, null, null)); if (separator==null) - add(new Sequence.Unwrap(new Element[] { e, Repeat.this }, null, null)); + add(new Sequence.Unwrap(new Element[] { e, Repeat.this })); else - add(new Sequence.Unwrap(new Element[] { e, separator, Repeat.this }, new boolean[] { false, true, false }, null, null)); + add(new Sequence.Unwrap(new Element[] { e, separator, Repeat.this }, new boolean[] { false, true, false })); } if (maximal) for(Sequence s : this) s.noFollow = separator==null ? e : separator; } diff --git a/src/edu/berkeley/sbp/Sequence.java b/src/edu/berkeley/sbp/Sequence.java index 8995b5c..f21bb80 100644 --- a/src/edu/berkeley/sbp/Sequence.java +++ b/src/edu/berkeley/sbp/Sequence.java @@ -62,6 +62,7 @@ public abstract class Sequence extends Element implements Iterable { Position firstp() { return firstp; } public Iterator iterator() { return new ArrayIterator(elements); } + protected Sequence(Element[] elements) { this(elements, null, null); } protected Sequence(Element[] elements, HashSet and, HashSet not) { if (and!=null) for(Sequence s : and) { needs.add(s); s.needed.add(this); } if (not!=null) for(Sequence s : not) { hates.add(s); s.hated.add(this); } @@ -198,10 +199,10 @@ public abstract class Sequence extends Element implements Iterable { public static class Unwrap extends Sequence { private boolean[] drops; - public Unwrap(Element[] e, HashSet and, HashSet not) { super(e, and, not); this.drops = null; } - public Unwrap(Element[] e, boolean[] drops, HashSet and, HashSet not) { super(e, and, not); this.drops = drops; } - public Sequence and(Sequence s) { Sequence ret = new Unwrap(elements, drops, needs, hates); ret.needs(s); return ret; } - public Sequence not(Sequence s) { Sequence ret = new Unwrap(elements, drops, needs, hates); ret.hates(s); return ret; } + public Unwrap(Element[] e) { super(e); this.drops = null; } + public Unwrap(Element[] e, boolean[] drops) { super(e); this.drops = drops; } + public Sequence and(Sequence s) { Sequence ret = new Unwrap(elements, drops); ret.needs(s); return ret; } + public Sequence not(Sequence s) { Sequence ret = new Unwrap(elements, drops); ret.hates(s); return ret; } public Forest postReduce(Input.Location loc, Forest[] args) { for(int i=0; i