use of catdata.fqlpp.SetExp.Range in project fql by CategoricalData.
the class PPParser method toSet.
private static SetExp toSet(Object o) {
try {
Tuple5 t = (Tuple5) o;
String f = t.b.toString();
SetExp e = toSet(t.e);
return new SetExp.Apply(f, e);
} catch (Exception e) {
}
try {
int i = Integer.parseInt(o.toString());
return new Numeral(i);
} catch (Exception e) {
}
try {
Tuple3<?, ?, ?> t = (Tuple3<?, ?, ?>) o;
String y = t.b.toString();
if (y.equals("+")) {
return new SetExp.Plus(toSet(t.a), toSet(t.c));
} else if (y.equals("*")) {
return new SetExp.Times(toSet(t.a), toSet(t.c));
} else if (y.equals("^")) {
return new SetExp.Exp(toSet(t.a), toSet(t.c));
} else if (y.equals("union")) {
return new SetExp.Union(toSet(t.a), toSet(t.c));
} else if (y.equals("intersect")) {
return new Intersect(toSet(t.a), toSet(t.c));
} else if (t.a.toString().equals("{")) {
List tb = (List) t.b;
Set x = new HashSet();
for (Object uu : tb) {
x.add(toValue(uu));
}
return new SetExp.Const(x);
}
} catch (RuntimeException cce) {
}
try {
org.jparsec.functors.Pair<?, ?> p = (org.jparsec.functors.Pair<?, ?>) o;
if (p.a.toString().equals("dom")) {
return new SetExp.Dom(toFn(p.b));
} else if (p.a.toString().equals("cod")) {
return new SetExp.Cod(toFn(p.b));
} else if (p.a.toString().equals("range")) {
return new Range(toFn(p.b));
}
} catch (RuntimeException cce) {
}
try {
if (o.toString().equals("void")) {
return new SetExp.Zero();
} else if (o.toString().equals("unit")) {
return new SetExp.One();
} else if (o.toString().equals("prop")) {
return new SetExp.Prop();
}
throw new RuntimeException();
} catch (RuntimeException cce) {
}
return new SetExp.Var(o.toString());
}
Aggregations