}
/** the empty sequence (matches the empty string) */
- static final Sequence empty = new Sequence.Constant.Empty();
- public static Sequence empty() { return empty; }
+ public static Sequence newEmptySequence() { return new Sequence.Constant.Empty(); }
/** after matching the sequence, do not add anything to the output tree */
- public static Sequence drop(Element[] e) { return new Constant.Drop(e); }
+ public static Sequence newDropSequence(Element[] e) { return new Constant.Drop(e); }
/** after matching the sequence, insert a constant into the output tree */
- public static Sequence constant(Element[] e, Object o) { return new Constant(e, o); }
+ public static Sequence newConstantSequence(Element[] e, Object o) { return new Constant(e, o); }
/** 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); }
+ public static Sequence newSingletonSequence(Element[] e, int idx) { return new Singleton(e, idx); }
+ public static Sequence newSingletonSequence(Element e) { return newSingletonSequence(new Element[] { e }, 0); }
/**
* after matching the sequence, create the specified output tree
* @param drops only elements of <tt>e</tt> whose corresponding <tt>boolean</tt> in <tt>drops</tt>
* is <i>false</i> will be included in the output tree
**/
- public static Sequence rewritingSequence(Object tag, Element[] e, boolean[] drops) {
+ public static Sequence newRewritingSequence(Object tag, Element[] e, boolean[] drops) {
return new RewritingSequence(tag, e, drops); }
- public static Sequence regionRewritingSequence(Functor<Input.Region,Object> tagfunctor, Element[] e, boolean[] drops) {
- return new RegionRewritingSequence(tagfunctor, e, drops); }
+ public static Sequence newUnwrapSequence(Element[] e, Object tag, boolean[] drops) { return new Unwrap(e, tag, drops); }
////////////////////////////////////////////////////////////////////////////////
+ /** return a new sequence identical to this one, but with a positive conjunct <tt>s</tt> */
public Sequence and(Sequence s) { Sequence ret = dup(); ret.needs.add(s); return ret; }
+
+ /** return a new sequence identical to this one, but with a negative conjunct <tt>s</tt> */
public Sequence not(Sequence s) { Sequence ret = dup(); ret.hates.add(s); s.hated.add(ret); return ret; }
+
+ /** return a new sequence identical to this one, but with a follow-set restricted to <tt>a</tt> */
public Sequence followedBy(Atom a) { Sequence ret = dup(); ret.follow = a; return ret; }
Iterable<Sequence> needs() { return needs; }
Sequence _clone() { return new Singleton(elements,idx); }
}
- public static Sequence unwrap(Element[] e, Object tag, boolean[] drops) { return new Unwrap(e, tag, drops); }
static class Unwrap extends Sequence {
private boolean[] drops;
private final Object tag;