X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FSequence.java;h=5ee8433431ef5d25137fead50bdb7a8debedd86a;hp=44b30c572bacbedd2c5257abbb29bfb26f696db3;hb=0e17670bcfa7b0fe8eb3a2cac81f4b080a09fc98;hpb=6af13e9dda011e2416e4f0ee3cc347e8e7fcafd7 diff --git a/src/edu/berkeley/sbp/Sequence.java b/src/edu/berkeley/sbp/Sequence.java index 44b30c5..5ee8433 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 Topology 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); }