public void exitedProduction(Object production, boolean filtered, Object environment) {
}
public IConstructor filterAmbiguity(IConstructor ambCluster, Object environment) {
ISet alts = (ISet) ambCluster.get("alternatives");
if (alts.size() == 0) {
return null;
}
Environment env = (Environment) environment;
Result<IValue> var = env.getVariable("amb");
if (var != null && var instanceof ICallableValue) {
Type type = RascalTypeFactory.getInstance().nonTerminalType(ambCluster);
ICallableValue func = (ICallableValue) var;
try {
Result<IValue> result = func.call(
new Type[] {TF.setType(type)}, new IValue[] {alts}, null
);
if (result.getType().isBottom()) {
return ambCluster;
}
IConstructor r = (IConstructor) result.getValue();
if (TreeAdapter.isAmb(r)) {
ISet returnedAlts = TreeAdapter.getAlternatives(r);
if (returnedAlts.size() == 1) {
return (IConstructor) returnedAlts.iterator().next();
}
else if (returnedAlts.size() == 0) {
return null;
}
else {
return r;
}