Search in sources :

Example 1 with MplSch

use of catdata.mpl.Mpl.MplExp.MplSch in project fql by CategoricalData.

the class MplParser method toTheory.

private static MplExp toTheory(Object o) {
    Tuple3 t = (Tuple3) o;
    Tuple3 a = (Tuple3) t.a;
    Tuple3 b = (Tuple3) t.b;
    Tuple3 c = (Tuple3) t.c;
    Set<String> sorts = new HashSet<>((Collection<String>) a.b);
    List<Tuple3> symbols0 = (List<Tuple3>) b.b;
    List<Tuple3> equations0 = (List<Tuple3>) c.b;
    Map<String, Pair<MplType<String>, MplType<String>>> symbols = new HashMap<>();
    for (Tuple3 x : symbols0) {
        MplType<String> dom;
        MplType<String> args;
        Tuple3 zzz = (Tuple3) x.c;
        args = toType(zzz.a);
        dom = toType(zzz.c);
        List<String> name0s = (List<String>) x.a;
        for (String name : name0s) {
            if (symbols.containsKey(name)) {
                throw new DoNotIgnore("Duplicate symbol " + name);
            }
            symbols.put(name, new Pair<>(args, dom));
        }
    }
    Set<Pair<MplTerm<String, String>, MplTerm<String, String>>> equations = new HashSet<>();
    for (Tuple3 eq : equations0) {
        MplTerm<String, String> lhs = toTerm(eq.a);
        MplTerm<String, String> rhs = toTerm(eq.c);
        equations.add(new Pair<>(lhs, rhs));
    }
    return new MplSch<>(sorts, symbols, equations);
}
Also used : MplSch(catdata.mpl.Mpl.MplExp.MplSch) Tuple3(org.jparsec.functors.Tuple3) MplPair(catdata.mpl.Mpl.MplTerm.MplPair) Pair(catdata.Pair)

Aggregations

Pair (catdata.Pair)1 MplSch (catdata.mpl.Mpl.MplExp.MplSch)1 MplPair (catdata.mpl.Mpl.MplTerm.MplPair)1 Tuple3 (org.jparsec.functors.Tuple3)1