void reachable(HashSet<Sequence.Position> h) { /* do-nothing */ }
+ public Topology toAtom() { return dup(); }
+
/** equality is based on the underlying <tt>Topology</tt> */
public int hashCode() { return rt.hashCode(); }
/** add all positions reachable from the start of this Element to @rp */
abstract void reachable(HashSet<Sequence.Position> rp);
+ abstract Topology toAtom();
Forest epsilonForm() { throw new Error("no epsilon form: " + this); }
final boolean possiblyEpsilon(Walk.Cache cache) {
Boolean ret = cache==null ? null : cache.possiblyEpsilon.get(this);
////////////////////////////////////////////////////////////////////////////////
+ Topology toAtom() {
+ if (elements.length!=1) return null;
+ return elements[0].toAtom();
+ }
+
protected final Element[] elements;
final HashSet<Sequence> needs;
void reachable(HashSet<Sequence.Position> h) { for(Sequence s : alternatives) s.reachable(h); }
+ Topology toAtom() {
+ if (alternatives.size()==0) return null;
+ Topology ret = null;
+ for(Sequence s : this) {
+ Topology a = s.toAtom();
+ if (ret==null) ret = a.dup();
+ else ret.add(a.dup());
+ }
+ return ret;
+ }
+
/** adds an alternative */
public void add(Sequence s) { alternatives.add(s); }