import java.lang.reflect.*;
import java.lang.ref.*;
-/** juxtaposition; zero or more adjacent Elements; can specify a rewriting */
+/** <font color=green>juxtaposition; zero or more adjacent Elements; can specify a rewriting</font> */
public abstract class Sequence extends Element implements Iterable<Element> {
+ protected final Element[] elements;
+
+ final HashSet<Sequence> hated = new HashSet<Sequence>();
+
+ final HashSet<Sequence> needs = new HashSet<Sequence>();
+ final HashSet<Sequence> hates = new HashSet<Sequence>();
+
+ 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;
////////////////////////////////////////////////////////////////////////////////
- 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<Sequence> needs() { return needs; }
public Iterable<Sequence> hates() { return hates; }
- protected final Element[] elements;
-
- final HashSet<Sequence> needed = new HashSet<Sequence>();
- final HashSet<Sequence> hated = new HashSet<Sequence>();
- final HashSet<Sequence> needs = new HashSet<Sequence>();
- final HashSet<Sequence> hates = new HashSet<Sequence>();
-
- final Position firstp;
Position firstp() { return firstp; }
public Iterator<Element> iterator() { return new ArrayIterator<Element>(elements); }