X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FSequence.java;h=1d5634378dce266e177bcfaef05b0b34dd8829bb;hb=d28917b3c84c429e8fd6587717df9e90a894b18f;hp=44b30c572bacbedd2c5257abbb29bfb26f696db3;hpb=6af13e9dda011e2416e4f0ee3cc347e8e7fcafd7;p=sbp.git diff --git a/src/edu/berkeley/sbp/Sequence.java b/src/edu/berkeley/sbp/Sequence.java index 44b30c5..1d56343 100644 --- a/src/edu/berkeley/sbp/Sequence.java +++ b/src/edu/berkeley/sbp/Sequence.java @@ -7,15 +7,27 @@ import java.util.*; import java.lang.reflect.*; import java.lang.ref.*; -/** juxtaposition; zero or more adjacent Elements; can specify a rewriting */ +/** juxtaposition; zero or more adjacent Elements; can specify a rewriting */ public abstract class Sequence extends Element implements Iterable { + protected final Element[] elements; + + final HashSet hated = new HashSet(); + + final HashSet needs = new HashSet(); + final HashSet hates = new HashSet(); + + final Position firstp; + + public Atom follow = null; + public final Atom follow() { return follow; } + // Static Constructors ////////////////////////////////////////////////////////////////////////////// abstract Sequence _clone(); Sequence dup() { Sequence ret = _clone(); - for(Sequence s : needs) { ret.needs.add(s); s.needed.add(ret); } + for(Sequence s : needs) { ret.needs.add(s); } for(Sequence s : hates) { ret.hates.add(s); s.hated.add(ret); } ret.follow = follow; return ret; @@ -49,23 +61,12 @@ public abstract class Sequence extends Element implements Iterable { //////////////////////////////////////////////////////////////////////////////// - public Atom follow = null; - public final Topology follow() { return follow; } - - public Sequence and(Sequence s) { Sequence ret = dup(); ret.needs.add(s); s.needed.add(ret); return ret; } + public Sequence and(Sequence s) { Sequence ret = dup(); ret.needs.add(s); return ret; } public Sequence not(Sequence s) { Sequence ret = dup(); ret.hates.add(s); s.hated.add(ret); return ret; } public Iterable needs() { return needs; } public Iterable hates() { return hates; } - protected final Element[] elements; - - final HashSet needed = new HashSet(); - final HashSet hated = new HashSet(); - final HashSet needs = new HashSet(); - final HashSet hates = new HashSet(); - - final Position firstp; Position firstp() { return firstp; } public Iterator iterator() { return new ArrayIterator(elements); }