use of catdata.fql.decl.MapExp.Sub in project fql by CategoricalData.
the class FQLParser method toMapping.
@SuppressWarnings({ "rawtypes", "unchecked" })
private static MapExp toMapping(Object o) {
try {
Tuple3 p = (Tuple3) o;
Object p2 = p.b;
Object p3 = p.c;
Object o1 = p.a;
String p1 = p.a.toString();
if (p1.equals("fst")) {
return new Fst(toSchema(p2), toSchema(p3));
} else if (p1.equals("snd")) {
return new Snd(toSchema(p2), toSchema(p3));
} else if (p1.equals("unit")) {
return new TT(toSchema(p3), new HashSet<>((Collection<String>) p2));
} else if (p1.equals("subschema")) {
return new Sub(toSchema(p2), toSchema(p3));
} else if (p1.equals("inl")) {
return new Inl(toSchema(p2), toSchema(p3));
} else if (p1.equals("inr")) {
return new Inr(toSchema(p2), toSchema(p3));
} else if (p1.equals("iso1")) {
return new Iso(true, toSchema(p2), toSchema(p3));
} else if (p1.equals("iso2")) {
return new Iso(false, toSchema(p2), toSchema(p3));
} else if (p1.equals("eval")) {
return new Apply(toSchema(p2), toSchema(p3));
} else if (p2.toString().equals("then")) {
return new MapExp.Comp(toMapping(o1), toMapping(p3));
} else if (p2.toString().equals("*")) {
return new Prod(toMapping(o1), toMapping(p3));
} else if (p2.toString().equals("+")) {
return new Case(toMapping(o1), toMapping(p3));
}
} catch (RuntimeException re) {
}
if (o instanceof Tuple5) {
Tuple5 p = (Tuple5) o;
Object p2 = p.c;
Object p3 = p.e;
Object o1 = p.a;
return toMapConst(o1, toSchema(p2), toSchema(p3));
}
try {
org.jparsec.functors.Pair p = (org.jparsec.functors.Pair) o;
String p1 = p.a.toString();
Object p2 = p.b;
switch(p1) {
case "id":
return new Id(toSchema(p2));
case "curry":
return new Curry(toMapping(p2));
case "void":
return new FF(toSchema(p2));
case "opposite":
return new Opposite(toMapping(p2));
default:
break;
}
} catch (RuntimeException re) {
}
if (o instanceof String) {
return new MapExp.Var(o.toString());
}
throw new RuntimeException("Cannot parse " + o);
}
Aggregations