- public static class PreSequence {
- public final HashSet<PreSequence> needs = new HashSet<PreSequence>();
- public final HashSet<PreSequence> hates = new HashSet<PreSequence>();
- public final HashSet<Sequence> hatess = new HashSet<Sequence>();
- public /*final*/ String tag;
- public final Object[] o;
- public final boolean keeper;
-
- 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) {
- if (o==null) return new Element[0];
- Element[] o2 = new Element[o.length];
- drops = new boolean[o.length];
- int j = 0;
- 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);
- 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 PreBrace) o2[j]
- else o2[j] = (Element)oi;
-
- if (dropAll.contains(o2[j])) drops[j] = true;
-
- o2[j] = o2[j];
- j++;
- }
- if (ws == null || o2.length <= 1) return o2;
- Element[] ret = new Element[o2.length*2-1];
- boolean[] drops2 = new boolean[ret.length];
- for(int i=0; i<o2.length; i++) {
- if (i>0) { ret[i*2-1] = ws; drops2[i*2-1] = true; }
- ret[i*2] = o2[i];
- drops2[i*2] = drops[i];
- }
- drops = drops2;
- return ret;
+ public static class PreSequence {
+ public final HashSet<PreSequence> needs = new HashSet<PreSequence>();
+ public final HashSet<PreSequence> hates = new HashSet<PreSequence>();
+ public final HashSet<Sequence> hatess = new HashSet<Sequence>();
+ public /*final*/ String tag;
+ public final Object[] o;
+ public final boolean keeper;
+
+ 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(Union u, HashSet<Sequence> set) {
+ if (o==null) return new Element[0];
+ Element[] o2 = new Element[o.length];
+ drops = new boolean[o.length];
+ int j = 0;
+ 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();
+ 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 Rep) o2[j] = ((Rep)oi).build();
+ else o2[j] = (Element)oi;
+
+ if (dropAll.contains(o2[j])) drops[j] = true;
+
+ o2[j] = o2[j];
+ j++;