use of catdata.fql.decl.SigExp.Union in project fql by CategoricalData.
the class FQLParser method toSchema.
@SuppressWarnings({ "rawtypes", "unchecked" })
private static SigExp toSchema(Object o) {
try {
Tuple3<?, ?, ?> t = (Tuple3<?, ?, ?>) o;
Token z = (Token) t.b;
String y = z.toString();
switch(y) {
case "+":
return new SigExp.Plus(toSchema(t.a), toSchema(t.c));
case "*":
return new SigExp.Times(toSchema(t.a), toSchema(t.c));
case "^":
return new SigExp.Exp(toSchema(t.a), toSchema(t.c));
case "union":
return new Union(toSchema(t.a), toSchema(t.c));
default:
break;
}
} catch (RuntimeException cce) {
}
try {
org.jparsec.functors.Pair p = (org.jparsec.functors.Pair) o;
if (p.a.toString().equals("unit")) {
return new SigExp.One(new HashSet<>((Collection<String>) p.b));
} else if (p.a.toString().equals("opposite")) {
return new SigExp.Opposite(toSchema(p.b));
}
} catch (RuntimeException cce) {
}
try {
if (o.toString().equals("void")) {
return new SigExp.Zero();
} else if (o.toString().equals("?")) {
return new Unknown("?" + unknown_idx++);
}
throw new RuntimeException();
} catch (RuntimeException cce) {
}
try {
return toSchemaConst(o);
} catch (RuntimeException cce) {
}
return new SigExp.Var(o.toString());
}
Aggregations