use of catdata.fqlpp.FunctorExp.One in project fql by CategoricalData.
the class PPParser method toFtr.
private static FunctorExp toFtr(Object o) {
try {
Tuple5 p = (Tuple5) o;
if (p.a.toString().equals("apply")) {
FunctorExp f = toFtr(p.b);
FunctorExp e = toFtr(p.e);
return new Apply(f, e);
}
if (p.e.toString().equals("Set")) {
return p.c.toString().equals("Set") ? toSetSet(o) : toInstConst(o);
} else if (p.e.toString().equals("Cat")) {
return toCatFtrConst(o);
} else {
if (p.e instanceof Tuple3) {
Tuple3 t = (Tuple3) p.e;
if ((t.a.toString().equals("Cat") || t.a.toString().equals("Set")) && t.b.toString().equals("^")) {
return toFinalConst(o);
} else {
throw new RuntimeException();
}
}
return toMapConst(o);
}
} catch (Exception e) {
}
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(toCat(p2), toCat(p3));
} else if (p1.equals("snd")) {
return new Snd(toCat(p2), toCat(p3));
} else if (p1.equals("inl")) {
return new Inl(toCat(p2), toCat(p3));
} else if (p1.equals("inr")) {
return new Inr(toCat(p2), toCat(p3));
} else if (p1.equals("iso1")) {
return new Iso(true, toCat(p2), toCat(p3));
} else if (p1.equals("iso2")) {
return new Iso(false, toCat(p2), toCat(p3));
} else if (p1.equals("eval")) {
return new Eval(toCat(p2), toCat(p3));
} else if (p2.toString().equals(";")) {
return new Comp(toFtr(o1), toFtr(p3));
} else if (p2.toString().equals("*")) {
return new Prod(toFtr(o1), toFtr(p3));
} else if (p2.toString().equals("+")) {
return new Case(toFtr(o1), toFtr(p3));
} else if (p2.toString().equals("^")) {
return new Exp(toFtr(o1), toFtr(p3));
} else if (p1.equals("unit")) {
return new One(toCat(p.b), toCat(p.c));
} else if (p1.equals("void")) {
return new Zero(toCat(p.b), toCat(p.c));
} else if (p1.equals("pushout")) {
return new Pushout(p.b.toString(), p.c.toString());
}
} catch (RuntimeException re) {
}
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(toCat(p2));
case "prop":
return new Prop(toCat(p2));
case "curry":
return new Curry(toFtr(p2));
case "uncurry":
return new Uncurry(toFtr(p2));
case "delta":
case "sigma":
case "pi":
return new Migrate(toFtr(p2), p1);
case "ff":
return new FF(toCat(p2));
case "tt":
return new TT(toCat(p2));
case "dom":
return new Dom(p2.toString(), true);
case "cod":
return new Dom(p2.toString(), false);
case "pivot":
return new Pivot(toFtr(p2), true);
case "unpivot":
return new Pivot(toFtr(p2), false);
default:
break;
}
} catch (RuntimeException re) {
}
if (o instanceof String) {
return new Var(o.toString());
}
throw new RuntimeException("Bad: " + o);
}
Aggregations