HashSet<Sequence> temp = new HashSet<Sequence>();
for(PreSequence pre : s[i]) {
pre.hatess.addAll(seqs);
- Sequence seq = pre.buildSequence(null, n, false, dropAll);
+ Sequence seq = pre.buildSequence(n, false, dropAll);
temp.add(seq);
//for(Sequence dom : seqs) seq.hates.add(dom);
n.add(seq);
private final boolean maximal;
private final boolean zero;
public Rep(Element e, Element s, boolean maximal, boolean zero) { this.e = e; this.s = s; this.zero = zero; this.maximal = maximal;}
- public Element build(Element ws) {
- Element sep = null;
- if (ws==null) sep = s;
- else if (s==null) sep = ws;
- else {
- Union ws2 = new Union(e + "/" + s + "/" + ws, true);
- ws2.add(Sequence.singleton(new Element[] { ws, s, ws }, 0, null, null));
- sep = ws2;
- }
+ public Element build() {
+ Element sep = s;
Element ret = zero ? Repeat.many0(e, sep) : Repeat.many1(e, sep);
return maximal ? Repeat.maximal(ret) : ret;
}
public PreSequence(Object[] o, String tag) { this(o, tag, false); }
public PreSequence(Object[] o, String tag, boolean keeper) { this.o = o; this.tag = tag; this.keeper = keeper; }
boolean[] drops = null;
- public Element[] expand(Element ws, Union u, HashSet<Sequence> set) {
+ public Element[] expand(Union u, HashSet<Sequence> set) {
if (o==null) return new Element[0];
Element[] o2 = new Element[o.length];
drops = new boolean[o.length];
for(int i=0; i<o.length; i++) {
Object oi = o[i];
if (oi instanceof MyDrop) { oi = ((MyDrop)oi).o; drops[j] = true; }
- if (oi instanceof PreSequence) o2[j] = ((PreSequence)oi).buildUnion(ws);
+ if (oi instanceof PreSequence) o2[j] = ((PreSequence)oi).buildUnion();
else if (oi==SELF) o2[j] = u.new Subset("(("+u+"))", set);
else if (oi instanceof MyLift) { o2[j] = CharToken.string(tag = ((MyLift)oi).s); drops[j] = true; }
else if (oi instanceof String) { o2[j] = CharToken.string( ((String)oi) ); drops[j] = true; }
- else if (oi instanceof Rep) o2[j] = ((Rep)oi).build(ws);
+ else if (oi instanceof Rep) o2[j] = ((Rep)oi).build();
//else if (oi instanceof PreBrace) o2[j]
else o2[j] = (Element)oi;
o2[j] = o2[j];
j++;
}
+ return o2;
+ /*
if (ws == null || o2.length <= 1) return o2;
Element[] ret = new Element[o2.length*2-1];
boolean[] drops2 = new boolean[ret.length];
}
drops = drops2;
return ret;
+ */
}
- public Union buildUnion(Element ws) {
+ public Union buildUnion() {
Union u = new Union("???");
- u.add(buildSequence(ws, u));
+ u.add(buildSequence(u));
return u;
}
- public Sequence buildSequence(Element ws, Union u) { return buildSequence(ws, u, false, false); }
- public Sequence buildSequence(Element ws, Union u, boolean lame, boolean dropAll) {
+ public Sequence buildSequence(Union u) { return buildSequence(u, false, false); }
+ public Sequence buildSequence(Union u, boolean lame, boolean dropAll) {
HashSet<Sequence> and = new HashSet<Sequence>();
HashSet<Sequence> not = new HashSet<Sequence>();
for(PreSequence p : needs) {
- Sequence ps = p.buildSequence(ws, u, true, dropAll);
+ Sequence ps = p.buildSequence(u, true, dropAll);
u.add(ps);
and.add(ps);
}
for(Sequence p : hatess) not.add(p);
for(PreSequence p : hates) {
- Sequence ps = p.buildSequence(ws, u, true, dropAll);
+ Sequence ps = p.buildSequence(u, true, dropAll);
u.add(ps);
not.add(ps);
}
HashSet<Sequence> set = new HashSet<Sequence>();
- Element[] expansion = expand(ws, u, set);
+ Element[] expansion = expand(u, set);
boolean keeper = this.keeper;
Sequence ret = dropAll || lame || keeper ? Sequence.drop(expansion, and, not, lame) : null;
if (ret==null && tag!=null) {