use of catdata.opl.OplExp.OplGround in project fql by CategoricalData.
the class OplOps method visit.
@Override
public OplObject visit(Program<OplExp> env, OplInst0 e) {
OplObject zzz = ENV.get(e.P.S);
if (!(zzz instanceof OplSchema)) {
throw new RuntimeException("Not a SCHEMA: " + e.P.S);
}
for (Object k2 : e.imports) {
String k = (String) k2;
OplExp o = env.exps.get(k);
OplInst0 a;
if (o instanceof OplInst0) {
a = (OplInst0) o;
} else if (o instanceof OplGround) {
a = ((OplGround) o).validate(((OplInst) ENV.get(k)).S);
} else {
throw new RuntimeException("Not an instance: " + k);
}
Util.putAllSafely(e.P.gens, a.P.gens);
e.P.equations.addAll(a.P.equations);
e.P.prec.putAll(a.P.prec);
// Util.putAllSafely(e.P.prec, a.P.prec);
}
OplPres P = (OplPres) visit(env, e.P);
OplInst ret = new OplInst(e.P.S, "?", "none");
OplObject S0 = ENV.get(e.P.S);
if (!(S0 instanceof OplSchema)) {
throw new RuntimeException("Not a schema: " + e.P.S);
}
OplSchema S = (OplSchema) S0;
ret.validate(S, P, null);
return ret;
}
use of catdata.opl.OplExp.OplGround in project fql by CategoricalData.
the class OplParser method toModel2.
private static OplExp toModel2(Object o) {
if (!o.toString().contains("tables")) {
throw new RuntimeException();
}
Tuple3 t = (Tuple3) o;
Tuple3 b = (Tuple3) t.b;
org.jparsec.functors.Pair c = (org.jparsec.functors.Pair) t.c;
Tuple3 y = (Tuple3) b.a;
List<Tuple3> sorts = (List<Tuple3>) y.b;
Map<String, List<String>> sorts0 = new HashMap<>();
for (Tuple3 x : sorts) {
String s = x.a.toString();
List<String> s0 = (List<String>) x.c;
if (sorts0.containsKey(s)) {
throw new DoNotIgnore("Duplicate sort: " + s);
}
sorts0.put(s, s0);
}
Map<String, Map<String, String>> symbols0 = new HashMap<>();
Tuple3 z = (Tuple3) b.b;
List<Tuple3> q = (List<Tuple3>) z.b;
Tuple3 z0 = (Tuple3) b.c;
q.addAll((Collection<? extends Tuple3>) z0.b);
for (Tuple3 r : q) {
List<Tuple5> u = (List<Tuple5>) r.c;
String fname = (String) r.a;
if (symbols0.containsKey(fname)) {
throw new DoNotIgnore("Duplicate symbol " + fname);
}
Map<String, String> toadd = new HashMap<>();
for (Tuple5 e : u) {
String args = (String) e.b;
String ret = (String) e.d;
if (toadd.containsKey(args)) {
throw new DoNotIgnore("Duplicate argument at " + args);
}
toadd.put(args, ret);
}
symbols0.put(fname, toadd);
}
return new OplGround(sorts0, symbols0, c.b.toString());
}
Aggregations