public void grammar(NameEmbedding Gt, NameEmbedding Gd, Grammar GT, Grammar GG) {
        d.add("c", "c", false, true);
        e.add("c", "c", false, true);
        // types
        T = new LanguageBuilder<Object>();
        T.copy(GT);
        T.startSymbol = GT.startSymbol;
        String tprefix = t.prefix;
        t = new NameEmbedding(Gt);
        t.prefix = tprefix;
        types(t, T, GT.startSymbol);

        // environments
        E = new LanguageBuilder<Object>();
        E.def("env").start().t("nil").or().t("pair").nt(GT.startSymbol).nt("env").or().t("Eta").end();
        E.copy(GT);
        String eprefix = e.prefix;
        e = new NameEmbedding(Gt);
        e.prefix = eprefix;
        types(new NameEmbedding(NameEmbedding.T_PREFIX), E, GT.startSymbol);

        // terms
        G = new LanguageBuilder<Object>();
        Type eString2;
        for (Production p : GG.ruleMap.values()) {
            String z = p.getProdName();
            String casez = "case_" + z;
            T.def(NODE_TYPE).start().t(OL_PREFIX + z).end();
            E.def(NODE_TYPE).start().t(OL_PREFIX + z).end();
            ExpressionBuilder<RuleBuilder, Object> r = G.def("e").start(0, Eta, dchi);

            ExtendedExpressionBuilder<RuleBuilder, Object> r2 = r.t(casez).nt("e", Eta, getProductionTypeStr(Gt, Gd, GT, p));
            ArrayList<Production> seqList = new ArrayList<Production>();
            breakOrList(p, seqList);
            for (Production p1 : seqList) {
                String a;
                Type eString = Eta;
                Type tString = getAbstactProductionOriginalTypeStr((AbstractProduction) p1, GT, Gt, null);
                if (p1 instanceof Terminal) { // z -> a
                    a = ((Terminal) p1).text;
                    r2 = r2.nt("e", eString, dchi);
                } else { // z -> a z1 ... zn
                    ArrayList<Production> ntList = new ArrayList<Production>();
                    breakSeqList(p1, ntList);
                    a = ((Terminal) ntList.get(0)).text;
                    for (int i = 1; i < ntList.size(); i++) {
                        NonTerminal nt = (NonTerminal) ntList.get(i);
                        Type type = getNodeTypeStr(Gt, Gd, GT, nt);
                        eString = cons("pair",type,eString);
                    }
                    r2 = r2.nt("e", eString, dchi);
                }
                eString2 = eString;
                for(Type dchiTLvar : dchiTL) {
                    tString = tString.renameVar(dchiTLvar.cons, dchi.cons);
                    eString2 = eString2.renameVar(dchiTLvar.cons, dchi.cons);
                }
                G.def("trans").start(0,Eta, tString).t(z+"_"+a+"By").nt("e",eString2,cons("V", tString)).end();
                S.trans(z+"_"+a+"By", TT.class);
            }
            r2.end();
        }
        S.state = new Variable[]{new Variable(consnat(erilex.data.generic.Pair.class,consnat(erilex.Grammar.class),consnat(erilex.tree.DeepTreeTransformer.class)),null)};

        G.def("e").start(1, Eta,dnchi).t("con").nt("c", Eta, consnatfuture("_Class", new Type("?", true, dnchi))).end();
        G.def("e").start(1, Eta, dchi).t("var").nt("i", Eta, dchi).end();
        G.def("e").start(0, Eta, cons("F", dchi1, dchi2)).t("abs").nt("e", cons("pair", dchi1,  Eta), dchi2).end();
        G.def("e").start(0, Eta, dchi).t("app").nt("e", Eta, cons("F", dchi1,dchi)).nt("e", Eta, dchi1).end();
        G.def("e").start(1, Eta, dchi).t("appcon").nt("c", Eta, consnatfuture("_Class", new Type("?", true, cons("F", dchi1,dchi)))).nt("e", Eta, dchi1).end();
        G.def("e").start(1, Eta, dchi).t("appappcon").nt("c", Eta, consnatfuture("_Class", new Type("?", true, cons("F", dchi2,cons("F", dchi1,dchi))))).nt("e", Eta, dchi2).nt("e", Eta, dchi1).end();
        G.def("e").start(0, Eta, dchi).t("fix").nt("e", cons("pair",dchi, Eta), dchi).end();
        G.def("e").start(0, Eta, cons("V", dchiTL[0])).t("visit").nt("e", Eta, state).nt("e",Eta,cons(TRL_NODE_CONS,ntchi, dchiTL[0])).end();// TODO replace hard coded "Chi" by actually dchi of the typing language
        G.def("e").start(0, Eta, state).t("state").end();
        G.def("i").start(0, cons("pair",dchi,Eta), dchi).t("z").end();
        G.def("i").start(0, cons("pair", dchi1, Eta), dchi).t("s").nt("i", Eta, dchi).end();
        G.def("e").start(0, Eta, dchi).t("error").end();
        G.def("e").start(0, Eta, dchi).t("ifx").nt("e", Eta, consnat(Boolean.class)).nt("e", Eta, dchi).nt("e", Eta, dchi).end();
        G.def("e").start(0, Eta, dchi).t("hd").nt("e", Eta, cons("List", dchi)).end();
        G.def("e").start(0, Eta, cons("List", dchiTL[0])).t("tl").nt("e", Eta, cons("List", dchiTL[0])).end();
        G.def("e").start(0, Eta, cons("List", dchiTL[0])).t("cns").nt("e", Eta, dchiTL[0]).nt("e", Eta, cons("List", dchiTL[0])).end();
        
    }