use of catdata.fql.decl.InstExp.Two in project fql by CategoricalData.
the class TransChecker method visit.
@Override
public Pair<String, String> visit(FQLProgram env, And e) {
InstExp v = env.insts.get(e.prop);
if (v == null) {
throw new RuntimeException("Missing instance: " + e.prop);
}
if (!(v instanceof Times)) {
throw new RuntimeException("Not a product in " + e);
}
Times v0 = (Times) v;
if (!v0.a.equals(v0.b)) {
throw new RuntimeException("Not the same prop in " + e);
}
if (!(env.insts.get(v0.a) instanceof Two)) {
throw new RuntimeException("Not a prop in " + e);
}
return new Pair<>(e.prop, v0.a);
}
use of catdata.fql.decl.InstExp.Two in project fql by CategoricalData.
the class TransChecker method visit.
@Override
public Pair<String, String> visit(FQLProgram env, Chi e) {
InstExp prop = env.insts.get(e.prop);
if (prop == null) {
throw new RuntimeException("Missing instance " + e.prop);
}
if (!(prop instanceof Two)) {
throw new RuntimeException("Not a prop " + e);
}
if (seen.contains(e.trans)) {
throw new RuntimeException("Circular transform " + e);
}
seen.add(e.trans);
TransExp t = env.transforms.get(e.trans);
if (t == null) {
throw new RuntimeException("Missing transform " + e.trans);
}
Pair<String, String> k = t.accept(env, this);
return new Pair<>(k.second, e.prop);
}
Aggregations