public InnerAmbiguous(Forest<?> f) { this.f = f; }
}
- static <T> Forest<T> singleton(Input.Region loc, Position p) {
- return create(loc, null, new Forest[] { }, false, true, p); }
+ static <T> Forest<T> singleton(Input.Region loc, Position p) { return create(loc, null, new Forest[] { }, false, p); }
static <T> Forest<T> singleton(Input.Region loc, Forest<T> body, Position p) { return body; }
- static <T> Forest<T> leaf(Input.Region loc, T tag, Position p) { return create(loc, tag, null, false, false, p); }
- public static <T> Forest<T> create(Input.Region loc, T tag, Forest<T>[] tokens, boolean unwrap, boolean singleton, Position p) {
- return new MyBody<T>(loc, tag, tokens, unwrap, singleton, p);
+ static <T> Forest<T> leaf(Input.Region loc, T tag, Position p) { return create(loc, tag, null, false, p); }
+ public static <T> Forest<T> create(Input.Region loc, T tag, Forest<T>[] tokens, boolean unwrap, Position p) {
+ return new MyBody<T>(loc, tag, tokens, unwrap, p);
}
// Body //////////////////////////////////////////////////////////////////////////////
ivbc.invoke(this, b, c);
}
- private final Input.Region location;
+ private final Input.Region location;
private final T tag;
private final Forest<T>[] tokens;
private final boolean unwrap;
- private final boolean singleton;
private final Sequence.Position reduction;
- private MyBody(Input.Region loc, T tag, Forest<T>[] tokens, boolean unwrap, boolean singleton, Position reduction) {
+ private MyBody(Input.Region loc, T tag, Forest<T>[] tokens, boolean unwrap, Position reduction) {
this.location = loc;
this.tag = tag;
this.tokens = tokens==null ? emptyForestArray : new Forest[tokens.length];
if (tokens != null) System.arraycopy(tokens, 0, this.tokens, 0, tokens.length);
if (tokens != null) for(int i=0; i<tokens.length; i++) if (tokens[i]==null) throw new Error(i+"");
this.unwrap = unwrap;
- this.singleton = singleton;
this.reduction = reduction;
}
public void gather(TaskList tl, HashSet<Tree<T>>[] ht, HashSet<Tree<T>> target) {
}
}
public void expand(TaskList tl, HashSet<Tree<T>> ht) {
- if (singleton) {
- tokens[0].expand(tl, ht);
- return;
- }
HashSet<Tree<T>>[] children = new HashSet[tokens.length];
tl.gather(this, children, ht);
for(int i=0; i<children.length; i++) {
}
public void expand(final int i, final TreeBuilder<T> h) {
- if (singleton) {
- tokens[0].visit(h, null, i);
- return;
- }
if (i==0) h.start(tag, location);
if (i==tokens.length) {
Sequence _clone() { return new Unwrap(elements, drops); }
public <T> Forest<T> postReduce(Input.Region loc, Forest<T>[] args, Position p) {
for(int i=0; i<args.length; i++) if (args[i]==null) throw new Error();
- if (drops==null) return Forest.create(loc, (T)tag, args, true, false, p);
+ if (drops==null) return Forest.create(loc, (T)tag, args, true, p);
int count = 0;
for(int i=0; i<drops.length; i++) if (!drops[i]) count++;
Forest<T>[] args2 = new Forest[count];
int j = 0;
for(int i=0; i<args.length; i++) if (!drops[i]) args2[j++] = args[i];
- return Forest.create(loc, (T)tag, args2, true, false, p);
+ return Forest.create(loc, (T)tag, args2, true, p);
}
}
int j = 0;
for(int i=0; i<args.length; i++) if (!drops[i]) args2[j++] = args[i];
//System.out.println("reduce \""+tag+"\"");
- return Forest.create(loc, (T)tag, args2, false, false, p);
+ return Forest.create(loc, (T)tag, args2, false, p);
}
public StringBuffer toString(StringBuffer sb, boolean spacing) {
int len = sb.length();