return epsilonForm;
}
- protected abstract <T> Forest<T> postReduce(Input.Location loc, Forest<T>[] args, Position p);
+ protected abstract <T> Forest<T> postReduce(Input.Region loc, Forest<T>[] args, Position p);
// Position //////////////////////////////////////////////////////////////////////////////
// Position /////////////////////////////////////////////////////////////////////////////////
- final <T> Forest<T> rewrite(Input.Location loc) { return rewrite(loc, true); }
- private final <T> Forest<T> rewrite(Input.Location loc, boolean epsilonCheck) {
+ final <T> Forest<T> rewrite(Input.Region loc) { return rewrite(loc, true); }
+ private final <T> Forest<T> rewrite(Input.Region loc, boolean epsilonCheck) {
if (epsilonCheck && this==firstp()) return epsilonForm();
for(int i=0; i<pos; i++) if (holder[i]==null) throw new Error("realbad " + i);
for(int i=pos; i<elements.length; i++) {
private final Object result;
public Constant(Element[] e, Object result) { super(e); this.result = result; }
Sequence _clone() { return new Constant(elements, result); }
- public <T> Forest<T> postReduce(Input.Location loc, Forest<T>[] args, Position p) {
+ public <T> Forest<T> postReduce(Input.Region loc, Forest<T>[] args, Position p) {
return (Forest<T>)Forest.leaf(loc, result, p);
}
static class Drop extends Constant {
private final int idx;
public Singleton(Element e) { this(new Element[] { e }, 0); }
public Singleton(Element[] e, int idx) { super(e); this.idx = idx; }
- public <T> Forest<T> postReduce(Input.Location loc, Forest<T>[] args, Position p) { return (Forest<T>)Forest.singleton(loc, args[idx], p); }
+ public <T> Forest<T> postReduce(Input.Region loc, Forest<T>[] args, Position p) { return (Forest<T>)Forest.singleton(loc, args[idx], p); }
Sequence _clone() { return new Singleton(elements,idx); }
}
public Unwrap(Element[] e, Object tag) { super(e); this.drops = null; this.tag = tag; }
public Unwrap(Element[] e, Object tag, boolean[] drops) { super(e); this.drops = drops; this.tag = tag; }
Sequence _clone() { return new Unwrap(elements, drops); }
- public <T> Forest<T> postReduce(Input.Location loc, Forest<T>[] args, Position p) {
+ 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);
int count = 0;
this.drops = drops == null ? new boolean[e.length] : drops;
for(int i=0; i<this.drops.length; i++) if (!this.drops[i]) count++;
}
- public <T> Forest<T> postReduce(Input.Location loc, Forest<T>[] args, Position p) {
+ public <T> Forest<T> postReduce(Input.Region loc, Forest<T>[] args, Position p) {
Forest<T>[] args2 = new Forest[count];
int j = 0;
for(int i=0; i<args.length; i++) if (!drops[i]) args2[j++] = args[i];