Search in sources :

Example 6 with Const

use of catdata.fql.decl.SigExp.Const in project fql by CategoricalData.

the class FQLParser method toSchemaConst.

@SuppressWarnings({ "rawtypes", "unchecked" })
private static SigExp toSchemaConst(Object y) {
    List<String> nodes = new LinkedList<>();
    List<Triple<String, String, String>> attrs = new LinkedList<>();
    List<Triple<String, String, String>> arrows = new LinkedList<>();
    List<Pair<List<String>, List<String>>> eqs = new LinkedList<>();
    Tuple4 s = (Tuple4) y;
    Tuple3 nodes0 = (Tuple3) s.a;
    Tuple3 attrs0 = (Tuple3) s.b;
    Tuple3 arrows0 = (Tuple3) s.c;
    Tuple3 eqs0 = (Tuple3) s.d;
    List nodes1 = (List) nodes0.b;
    List arrows1 = (List) arrows0.b;
    List eqs1 = (List) eqs0.b;
    for (Object o : nodes1) {
        nodes.add((String) o);
    }
    if (attrs0.b.toString().equals("ASWRITTEN")) {
        for (String k : nodes) {
            attrs.add(new Triple<>(k + "_att", k, "string"));
        }
    } else {
        List attrs1 = (List) attrs0.b;
        for (Object o : attrs1) {
            Tuple5 x = (Tuple5) o;
            attrs.add(new Triple<>((String) x.a, (String) x.c, (String) x.e));
        }
    }
    for (Object o : arrows1) {
        Tuple5 x = (Tuple5) o;
        arrows.add(new Triple<>((String) x.a, (String) x.c, (String) x.e));
    }
    for (Object o : eqs1) {
        Tuple3 x = (Tuple3) o;
        eqs.add(new Pair<>((List<String>) x.a, (List<String>) x.c));
    }
    Const c = new Const(nodes, attrs, arrows, eqs);
    return c;
}
Also used : Const(catdata.fql.decl.SigExp.Const) Triple(catdata.Triple) Tuple4(org.jparsec.functors.Tuple4) Tuple5(org.jparsec.functors.Tuple5) Tuple3(org.jparsec.functors.Tuple3) Pair(catdata.Pair)

Example 7 with Const

use of catdata.fql.decl.SigExp.Const in project fql by CategoricalData.

the class RaToFql method doAdom.

// always adom and guid
private static String doAdom(Const A, String a) {
    String k = a;
    List<Pair<List<String>, List<String>>> eeqs = new LinkedList<>();
    // List<Triple<String, String, String>> attrs = new LinkedList<>();
    // attrs.add(new Triple<>("att", "adom", "str"));
    List<Triple<String, String, String>> dd_attrs = new LinkedList<>();
    dd_attrs.add(new Triple<>("att", "x", "str"));
    List<Triple<String, String, String>> e_attrs = new LinkedList<>();
    List<String> bn = new LinkedList<>();
    bn.add("r");
    bn.add("d");
    List<Triple<String, String, String>> barrs = new LinkedList<>();
    List<Pair<String, String>> abn = new LinkedList<>();
    abn.add(new Pair<>("r", "guid"));
    abn.add(new Pair<>("d", "adom"));
    List<Pair<String, String>> abatt = new LinkedList<>();
    abatt.add(new Pair<>("att", "att"));
    List<Pair<String, String>> e_abatt = new LinkedList<>();
    List<Pair<String, List<String>>> abarr = new LinkedList<>();
    List<String> cn = new LinkedList<>();
    cn.add("r");
    cn.add("d");
    cn.add("m");
    List<Triple<String, String, String>> carrs = new LinkedList<>();
    carrs.add(new Triple<>("f", "m", "d"));
    List<Pair<String, String>> bcn = new LinkedList<>();
    bcn.add(new Pair<>("r", "r"));
    bcn.add(new Pair<>("d", "d"));
    List<Pair<String, List<String>>> bcarr = new LinkedList<>();
    List<Triple<String, String, String>> bbarrs = new LinkedList<>();
    bbarrs.add(new Triple<>("f", "a", "b"));
    bbarrs.add(new Triple<>("g", "a", "c"));
    bbarrs.add(new Triple<>("h", "b", "d"));
    bbarrs.add(new Triple<>("i", "c", "d"));
    List<String> bbn = new LinkedList<>();
    bbn.add("r");
    bbn.add("a");
    bbn.add("b");
    bbn.add("c");
    bbn.add("d");
    List<Triple<String, String, String>> ccarrs = new LinkedList<>();
    List<String> ccn = new LinkedList<>();
    List<Pair<List<String>, List<String>>> cceqs = new LinkedList<>();
    ccn.add("r");
    ccn.add("a");
    ccn.add("b");
    ccn.add("c");
    ccn.add("d");
    ccn.add("e");
    ccarrs.add(new Triple<>("f", "a", "b"));
    ccarrs.add(new Triple<>("g", "a", "c"));
    ccarrs.add(new Triple<>("h", "b", "d"));
    ccarrs.add(new Triple<>("i", "c", "d"));
    ccarrs.add(new Triple<>("ff", "e", "b"));
    ccarrs.add(new Triple<>("gg", "e", "c"));
    List<String> l1 = new LinkedList<>();
    l1.add("e");
    l1.add("ff");
    l1.add("h");
    List<String> l2 = new LinkedList<>();
    l2.add("e");
    l2.add("gg");
    l2.add("i");
    cceqs.add(new Pair<>(l1, l2));
    List<Triple<String, String, String>> ddarrs = new LinkedList<>();
    List<Pair<List<String>, List<String>>> ddeqs = new LinkedList<>();
    List<String> ddn = new LinkedList<>();
    ddn.add("r");
    ddn.add("v");
    ddn.add("w");
    ddn.add("x");
    ddn.add("y");
    ddarrs.add(new Triple<>("f", "v", "w"));
    ddarrs.add(new Triple<>("g", "w", "x"));
    ddarrs.add(new Triple<>("h", "x", "y"));
    ddarrs.add(new Triple<>("ff", "v", "w"));
    l1 = new LinkedList<>();
    l1.add("v");
    l1.add("f");
    l1.add("g");
    l2 = new LinkedList<>();
    l2.add("v");
    l2.add("ff");
    l2.add("g");
    ddeqs.add(new Pair<>(l1, l2));
    List<Pair<String, String>> ffn = new LinkedList<>();
    List<Pair<String, List<String>>> ffarr = new LinkedList<>();
    ffn.add(new Pair<>("r", "r"));
    ffn.add(new Pair<>("a", "m"));
    ffn.add(new Pair<>("b", "m"));
    ffn.add(new Pair<>("c", "m"));
    ffn.add(new Pair<>("d", "d"));
    l1 = new LinkedList<>();
    l1.add("m");
    ffarr.add(new Pair<>("f", l1));
    l1 = new LinkedList<>();
    l1.add("m");
    ffarr.add(new Pair<>("g", l1));
    l1 = new LinkedList<>();
    l1.add("m");
    l1.add("f");
    ffarr.add(new Pair<>("h", l1));
    l1 = new LinkedList<>();
    l1.add("m");
    l1.add("f");
    ffarr.add(new Pair<>("i", l1));
    List<Pair<String, String>> ggn = new LinkedList<>();
    ggn.add(new Pair<>("r", "r"));
    ggn.add(new Pair<>("a", "a"));
    ggn.add(new Pair<>("b", "b"));
    ggn.add(new Pair<>("c", "c"));
    ggn.add(new Pair<>("d", "d"));
    List<Pair<String, List<String>>> ggarr = new LinkedList<>();
    l1 = new LinkedList<>();
    l1.add("a");
    l1.add("f");
    ggarr.add(new Pair<>("f", l1));
    l1 = new LinkedList<>();
    l1.add("a");
    l1.add("g");
    ggarr.add(new Pair<>("g", l1));
    l1 = new LinkedList<>();
    l1.add("b");
    l1.add("h");
    ggarr.add(new Pair<>("h", l1));
    l1 = new LinkedList<>();
    l1.add("c");
    l1.add("i");
    ggarr.add(new Pair<>("i", l1));
    List<Pair<String, String>> hhn = new LinkedList<>();
    hhn.add(new Pair<>("r", "r"));
    hhn.add(new Pair<>("e", "v"));
    hhn.add(new Pair<>("a", "w"));
    hhn.add(new Pair<>("b", "w"));
    hhn.add(new Pair<>("c", "w"));
    hhn.add(new Pair<>("d", "y"));
    List<Pair<String, List<String>>> hharr = new LinkedList<>();
    l1 = new LinkedList<>();
    l1.add("w");
    hharr.add(new Pair<>("f", l1));
    l1 = new LinkedList<>();
    l1.add("w");
    hharr.add(new Pair<>("g", l1));
    l1 = new LinkedList<>();
    l1.add("w");
    l1.add("g");
    l1.add("h");
    hharr.add(new Pair<>("h", l1));
    l1 = new LinkedList<>();
    l1.add("w");
    l1.add("g");
    l1.add("h");
    hharr.add(new Pair<>("i", l1));
    l1 = new LinkedList<>();
    l1.add("v");
    l1.add("f");
    hharr.add(new Pair<>("ff", l1));
    l1 = new LinkedList<>();
    l1.add("v");
    l1.add("ff");
    hharr.add(new Pair<>("gg", l1));
    List<Pair<String, String>> iin = new LinkedList<>();
    iin.add(new Pair<>("guid", "r"));
    iin.add(new Pair<>("adom", "x"));
    List<Pair<String, List<String>>> iiarr = new LinkedList<>();
    int i = 0;
    for (Triple<String, String, String> m0 : A.arrows) {
        String m = m0.first;
        bn.add("m" + i);
        barrs.add(new Triple<>("i" + i, "r", "m" + i));
        barrs.add(new Triple<>("f" + i, "m" + i, "d"));
        abn.add(new Pair<>("m" + i, "guid"));
        List<String> l = new LinkedList<>();
        l.add("guid");
        abarr.add(new Pair<>("i" + i, l));
        l = new LinkedList<>();
        l.add("guid");
        l.add(m);
        abarr.add(new Pair<>("f" + i, l));
        carrs.add(new Triple<>("i" + i, "r", "m"));
        bcn.add(new Pair<>("m" + i, "m"));
        l = new LinkedList<>();
        l.add("r");
        l.add("i" + i);
        bcarr.add(new Pair<>("i" + i, l));
        l = new LinkedList<>();
        l.add("m");
        l.add("f");
        bcarr.add(new Pair<>("f" + i, l));
        bbarrs.add(new Triple<>("i" + i, "r", "a"));
        ccarrs.add(new Triple<>("i" + i, "r", "a"));
        ddarrs.add(new Triple<>("i" + i, "r", "w"));
        l = new LinkedList<>();
        l.add("r");
        l.add("i" + i);
        ffarr.add(new Pair<>("i" + i, l));
        l = new LinkedList<>();
        l.add("r");
        l.add("i" + i);
        ggarr.add(new Pair<>("i" + i, l));
        l = new LinkedList<>();
        l.add("r");
        l.add("i" + i);
        hharr.add(new Pair<>("i" + i, l));
        l = new LinkedList<>();
        l.add("r");
        l.add("i" + i);
        l.add("g");
        iiarr.add(new Pair<>(m, l));
        i++;
    }
    Const b = new Const(bn, e_attrs, barrs, eeqs);
    // F
    MapExp.Const ab = new MapExp.Const(abn, e_abatt, abarr, b, A);
    Const c = new Const(cn, e_attrs, carrs, eeqs);
    // G
    MapExp.Const bc = new MapExp.Const(bcn, e_abatt, bcarr, b, c);
    Const bb = new Const(bbn, e_attrs, bbarrs, eeqs);
    Const cc = new Const(ccn, e_attrs, ccarrs, cceqs);
    Const dd = new Const(ddn, dd_attrs, ddarrs, ddeqs);
    MapExp.Const ff = new MapExp.Const(ffn, e_abatt, ffarr, bb, c);
    MapExp.Const gg = new MapExp.Const(ggn, e_abatt, ggarr, bb, cc);
    MapExp.Const hh = new MapExp.Const(hhn, e_abatt, hharr, c, dd);
    MapExp.Const ii = new MapExp.Const(iin, abatt, iiarr, A, dd);
    String ret = "///////////////\n";
    ret += "schema " + k + "_B = " + b + "\n\n";
    ret += "mapping " + k + "_F = " + ab + " : " + k + "_B -> " + a + "\n\n";
    ret += "schema " + k + "_C = " + c + "\n\n";
    ret += "mapping " + k + "_G = " + bc + " : " + k + "_B -> " + k + "_C\n\n";
    ret += "schema " + k + "_BB = " + bb + "\n\n";
    ret += "schema " + k + "_CC = " + cc + "\n\n";
    ret += "schema " + k + "_DD = " + dd + "\n\n";
    ret += "mapping " + k + "_FF = " + ff + " : " + k + "_BB -> " + k + "_C\n\n";
    ret += "mapping " + k + "_GG = " + gg + " : " + k + "_BB -> " + k + "_CC\n\n";
    ret += "mapping " + k + "_HH = " + hh + " : " + k + "_CC -> " + k + "_DD\n\n";
    ret += "mapping " + k + "_II = " + ii + " : " + a + " -> " + k + "_DD\n\n";
    ret += "//////////////\n";
    return ret;
// emit as "as_rel"
}
Also used : Const(catdata.fql.decl.SigExp.Const) Triple(catdata.Triple) MapExp(catdata.fql.decl.MapExp) Pair(catdata.Pair)

Example 8 with Const

use of catdata.fql.decl.SigExp.Const in project fql by CategoricalData.

the class RaToFql method transSQLSchema.

private static String transSQLSchema(List<Pair<String, EExternal>> in) {
    List<Pair<List<String>, List<String>>> eqs = new LinkedList<>();
    List<Triple<String, String, String>> arrows = new LinkedList<>();
    List<Triple<String, String, String>> attrs = new LinkedList<>();
    List<String> nodes = new LinkedList<>();
    List<Pair<String, List<Pair<Object, Object>>>> inodes = new LinkedList<>();
    List<Pair<String, List<Pair<Object, Object>>>> iattrs = new LinkedList<>();
    List<Pair<String, List<Pair<Object, Object>>>> iarrows = new LinkedList<>();
    String adom = "adom";
    nodes.add(adom);
    List<Pair<Object, Object>> adomT = new LinkedList<>();
    LinkedList<Pair<Object, Object>> attT = new LinkedList<>();
    inodes.add(new Pair<>(adom, adomT));
    iattrs.add(new Pair<>("att", attT));
    attrs.add(new Triple<>("att", adom, "str"));
    Set<Object> enums = new HashSet<>();
    Map<String, Integer> dom1 = new HashMap<>();
    List<Pair<String, EExternal>> queries = new LinkedList<>();
    int count = 0;
    Set<String> seen = new HashSet<>();
    Map<String, List<String>> cols = new HashMap<>();
    for (Pair<String, EExternal> kk0 : in) {
        EExternal k0 = kk0.second;
        // String key = kk0.first;
        if (k0 instanceof ECreateTable) {
            ECreateTable k = (ECreateTable) k0;
            if (seen.contains(k.name)) {
                throw new RuntimeException("Duplicate name: " + k.name);
            }
            if (k.name.equals("adom") || k.name.equals("att")) {
                throw new RuntimeException("The names adom and att cannot be used.");
            }
            seen.add(k.name);
            nodes.add(k.name);
            inodes.add(new Pair<>(k.name, new LinkedList<>()));
            List<String> lcols = new LinkedList<>();
            for (Pair<String, String> col : k.types) {
                lcols.add(col.first);
                if (seen.contains(col.first)) {
                    throw new RuntimeException("Duplicate name: " + col.first);
                }
                seen.add(col.first);
                arrows.add(new Triple<>(k.name + "_" + col.first, k.name, adom));
                iarrows.add(new Pair<>(k.name + "_" + col.first, new LinkedList<>()));
            }
            cols.put(k.name, lcols);
        }
        if (k0 instanceof EInsertValues) {
            EInsertValues k = (EInsertValues) k0;
            List<String> lcols = cols.get(k.target);
            for (List<String> tuple : k.values) {
                if (lcols.size() != tuple.size()) {
                    throw new RuntimeException("Column size mismatch " + tuple + " in " + k.target);
                }
                List<Pair<Object, Object>> node = lookup2(k.target, inodes);
                if (node == null) {
                    throw new RuntimeException("Missing table " + k.target);
                }
                String id = "" + count++;
                node.add(new Pair<>(id, id));
                for (int colNum = 0; colNum < tuple.size(); colNum++) {
                    Integer xxx = dom1.get(tuple.get(colNum));
                    if (xxx == null) {
                        dom1.put(tuple.get(colNum), count);
                        enums.add(tuple.get(colNum));
                        adomT.add(new Pair<>(count, count));
                        attT.add(new Pair<>(count, "\"" + tuple.get(colNum) + "\""));
                        xxx = count;
                        count++;
                    }
                    List<Pair<Object, Object>> yyy = lookup2(k.target + "_" + lcols.get(colNum), iarrows);
                    if (yyy == null) {
                        throw new RuntimeException("Anomaly: please report");
                    }
                    yyy.add(new Pair<>(id, xxx));
                }
            }
        }
        if (k0 instanceof EFlower || k0 instanceof EUnion || k0 instanceof EDiff || k0 instanceof EED) {
            queries.add(kk0);
        }
    }
    Const exp = new Const(nodes, attrs, arrows, eqs);
    InstExp.Const inst = new InstExp.Const(inodes, iattrs, iarrows, new Var("S"));
    // int ctx = 0;
    String xxx = "\n\n";
    Map<String, String> schemas = new HashMap<>();
    Map<String, Const> schemas0 = new HashMap<>();
    Map<String, Boolean> done = new HashMap<>();
    for (Pair<String, EExternal> gh0 : queries) {
        String k = gh0.first;
        EExternal gh = gh0.second;
        if (gh instanceof EFlower) {
            EFlower fl = (EFlower) gh;
            Pair<String, Const> yyy = trans(exp, fl, k);
            xxx += yyy.first + "\n\n";
            schemas.put(k, k + "Schema");
            schemas0.put(k, yyy.second);
        } else if (gh instanceof EUnion) {
            EUnion g = (EUnion) gh;
            String s1 = schemas.get(g.l);
            schemas.put(k, s1);
            schemas0.put(k, schemas0.get(g.l));
            xxx += longSlash + "\n/* Translation of " + k + "  */\n" + longSlash;
            if (g.distinct) {
                xxx += "\n\n" + "instance " + k + "_temp = (" + g.l + " + " + g.r + ")";
                xxx += "\n\n" + "instance " + k + " = relationalize " + k + "_temp";
            } else {
                xxx += "\n\n" + "instance " + k + " = (" + g.l + " + " + g.r + ")";
            }
            xxx += "\n\n";
        } else if (gh instanceof EDiff) {
            String f1x = ((EDiff) gh).l;
            String f2x = ((EDiff) gh).r;
            String s1 = schemas.get(f1x);
            Const s1x = schemas0.get(f1x);
            schemas.put(k, s1);
            String f1y = doAdom(s1x, s1);
            if (!done.containsKey(s1)) {
                xxx += "\n\n" + f1y;
                done.put(s1, true);
            }
            xxx += doAdom2(s1, f1x, k + "_l");
            xxx += doAdom2(s1, f2x, k + "_r");
            String f1 = k + "_l" + "_rel";
            String f2 = k + "_r" + "_rel";
            xxx += longSlash + "\n/* Translation of " + k + "  */\n" + longSlash;
            xxx += "\n\ninstance " + k + "prp = prop " + s1;
            xxx += "\n\ninstance " + k + "one = unit " + s1;
            xxx += "\n\ninstance " + k + "prp2 = (" + k + "prp * " + k + "prp)";
            xxx += "\n\ntransform " + k + f1 + "t = " + k + "one.unit " + f1;
            xxx += "\n\ntransform " + k + f2 + "t = " + k + "one.unit " + f2;
            xxx += "\n\ntransform " + k + f1 + "tchi = " + k + "prp.char " + k + f1 + "t";
            xxx += "\n\ntransform " + k + f2 + "tchi = " + k + "prp.char " + k + f2 + "t";
            xxx += "\n\ntransform " + k + "n = (" + k + f2 + "tchi then " + k + "prp.not)";
            xxx += "\n\ntransform " + k + "j1 = " + k + "prp2.(" + k + f1 + "tchi * " + k + "n)";
            xxx += "\n\ntransform " + k + "j2 = (" + k + "j1 then " + k + "prp2.and)";
            if (((EDiff) gh).distinct) {
                xxx += "\n\ninstance " + k + "temp = kernel " + k + "j2";
                xxx += "\n\ninstance " + k + " = relationalize " + k + "temp";
            } else {
                xxx += "\n\ninstance " + k + " = kernel " + k + "j2";
            }
            xxx += "\n\n";
        } else if (gh instanceof EED) {
            EED c = (EED) gh;
            MapExp.Const f = doED(cols, c.from1, c.where1, exp);
            Const src = (Const) f.src;
            c.from2.putAll(c.from1);
            c.where2.addAll(c.where1);
            MapExp.Const g = doED(cols, c.from2, c.where2, exp);
            List<Pair<String, String>> l = new LinkedList<>();
            for (String x : src.nodes) {
                l.add(new Pair<>(x, x));
            }
            List<Pair<String, List<String>>> em = new LinkedList<>();
            for (Triple<String, String, String> e : src.arrows) {
                List<String> y = new LinkedList<>();
                y.add(e.second);
                y.add(e.first);
                em.add(new Pair<>(e.first, y));
            }
            MapExp.Const i = new MapExp.Const(l, new LinkedList<>(), em, f.src, g.src);
            xxx += longSlash + "\n/* Translation of " + k + " */\n" + longSlash;
            xxx += "\n\nschema " + k + "A = " + f.src;
            xxx += "\n\nschema " + k + "E = " + g.src;
            xxx += "\n\nmapping " + k + "I = " + i + " : " + k + "A -> " + k + "E";
            xxx += "\n\nmapping " + k + " = " + g + " : " + k + "E -> S";
            xxx += "\n\n";
        } else {
            throw new RuntimeException();
        }
    }
    String enum0 = "";
    boolean b = false;
    for (Object o : enums) {
        if (b) {
            enum0 += ", ";
        }
        b = true;
        enum0 += "\"" + o + "\"";
    }
    String comment = "//schema S and instance I represent the entire input database.\n\n";
    String preS = "enum str = { " + enum0 + " }";
    return comment + preS + "\n\nschema S = " + exp + "\n\ninstance I = " + inst + " : S" + xxx;
}
Also used : Var(catdata.fql.decl.SigExp.Var) Pair(catdata.Pair) Const(catdata.fql.decl.SigExp.Const) Triple(catdata.Triple) InstExp(catdata.fql.decl.InstExp) MapExp(catdata.fql.decl.MapExp)

Example 9 with Const

use of catdata.fql.decl.SigExp.Const in project fql by CategoricalData.

the class SigExpChecker method visit.

@Override
public SigExp visit(FQLProgram env, Union e) {
    SigExp lt = e.l.typeOf(env);
    SigExp rt = e.r.typeOf(env);
    if (!(lt instanceof Const)) {
        throw new RuntimeException(e.l + " does not have constant schema, has " + lt);
    }
    if (!(rt instanceof Const)) {
        throw new RuntimeException(e.r + " does not have constant schema, has " + lt);
    }
    Const lt0 = (Const) lt;
    Const rt0 = (Const) rt;
    Set<String> nodes = new HashSet<>(lt0.nodes);
    nodes.addAll(rt0.nodes);
    Set<Triple<String, String, String>> attrs = new HashSet<>(lt0.attrs);
    attrs.addAll(rt0.attrs);
    Set<Triple<String, String, String>> arrows = new HashSet<>(lt0.arrows);
    arrows.addAll(rt0.arrows);
    Set<Pair<List<String>, List<String>>> eqs = new HashSet<>(lt0.eqs);
    eqs.addAll(rt0.eqs);
    return new Const(new LinkedList<>(nodes), new LinkedList<>(attrs), new LinkedList<>(arrows), new LinkedList<>(eqs));
}
Also used : Triple(catdata.Triple) Const(catdata.fql.decl.SigExp.Const) HashSet(java.util.HashSet) Pair(catdata.Pair)

Example 10 with Const

use of catdata.fql.decl.SigExp.Const in project fql by CategoricalData.

the class FullQueryExpChecker method visit.

@Override
public Pair<SigExp, SigExp> visit(FQLProgram env, Match e) {
    List<String> x = new LinkedList<>(seen);
    Const s = e.src.typeOf(env).toConst(env);
    seen = x;
    Const t = e.dst.typeOf(env).toConst(env);
    seen = x;
    for (Pair<String, String> p : e.rel) {
        if (!contains(s.attrs, p.first)) {
            throw new RuntimeException(p.first + " is not in attriubtes of " + e.src);
        }
        if (!contains(t.attrs, p.second)) {
            throw new RuntimeException(p.second + " is not in attributes of " + e.dst);
        }
    }
    switch(e.kind) {
        case "delta sigma forward":
            return new Pair<>(t, s);
        case "delta pi forward":
            return new Pair<>(t, s);
        case "delta sigma backward":
            return new Pair<>(s, t);
        case "delta pi backward":
            return new Pair<>(s, t);
        default:
            throw new RuntimeException("Unknown kind: " + e.kind);
    }
}
Also used : Const(catdata.fql.decl.SigExp.Const) LinkedList(java.util.LinkedList) Pair(catdata.Pair)

Aggregations

Const (catdata.fql.decl.SigExp.Const)12 Pair (catdata.Pair)8 Triple (catdata.Triple)7 MapExp (catdata.fql.decl.MapExp)4 HashSet (java.util.HashSet)4 ResultSet (java.sql.ResultSet)3 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 InstExp (catdata.fql.decl.InstExp)2 Var (catdata.fql.decl.SigExp.Var)2 LinkedList (java.util.LinkedList)2 Comp (catdata.fql.decl.FullQueryExp.Comp)1 Delta (catdata.fql.decl.FullQueryExp.Delta)1 Pi (catdata.fql.decl.FullQueryExp.Pi)1 Sigma (catdata.fql.decl.FullQueryExp.Sigma)1 Signature (catdata.fql.decl.Signature)1 TransExp (catdata.fql.decl.TransExp)1 ExpPSM (catdata.fql.sql.ExpPSM)1 PSM (catdata.fql.sql.PSM)1