Sequence ret = _clone();
for(Sequence s : needs) { ret.needs.add(s); s.needed.add(ret); }
for(Sequence s : hates) { ret.hates.add(s); s.hated.add(ret); }
- ret.noFollow = noFollow;
+ ret.follow = follow;
return ret;
}
/** after matching the sequence, place the result of the <tt>idx</tt>th match in the output tree */
public static Sequence singleton(Element[] e, int idx) { return new Singleton(e, idx); }
+ public static Sequence singleton(Element e) { return singleton(new Element[] { e }, 0); }
/**
* after matching the sequence, create the specified output tree
////////////////////////////////////////////////////////////////////////////////
- public Element noFollow = null;
- public final Topology noFollow() { return noFollow==null ? null : Atom.toAtom(noFollow); }
+ public Element follow = null;
+ public final Topology follow() { return follow==null ? null : Atom.toAtom(follow); }
Topology toAtom() {
if (elements.length!=1) throw new RuntimeException("cannot invoke toAtom() on a Sequence with " + elements.length + " elements: " + this);
sb.append(elements[i].toString());
sb.append(' ');
}
+ if (follow != null) {
+ sb.append("-> ");
+ sb.append(follow);
+ }
return sb;
}
}
public StringBuffer toString(StringBuffer sb, boolean spacing) {
int len = sb.length();
+ if (tag != null)
+ sb.append("\""+StringUtil.escapify(tag.toString(),"\"\r\n")+"\":: ");
super.toString(sb, spacing);
len = sb.length()-len;
if (spacing) for(int i=0; i<50-len; i++) sb.append(' ');
- sb.append(" => ");
- sb.append(tag);
return sb;
}
}