public List<TypingRule> toTypingRules(Grammar g) {
        List<TypingRule> list = new ArrayList<TypingRule>();
        String a;
        String zn;
        Type env, type;
        for (Production p : g.ruleMap.values()) {
            String name = p.getProdName();
            if (name == null) {
                Utils.error(this, "Unsupported: grammars with auxiliary rules");
                continue;
            } else {

                Judgement z;
                List<Production> seqList = new ArrayList<Production>();
                breakOrList(p, seqList);

                for (Production pp : seqList) {
//                    in 
                    env = parseEnv(pp);
                    type = parseType(pp);
                    z = new Judgement(env, name, type);
                    int ari = parameterized ? ((AbstractProduction) pp).arity : 0; // set arity to 0 if not parameterize
                    if (pp instanceof Terminal) {
                        a = ((Terminal) pp).text;
                        list.add(new TypingRule(z, a, array0));
                    } else {
                        List<Judgement> l = new ArrayList<Judgement>();

			List<Production> seq = ((MultiSeq) pp).disjuncts;
                        a = ((Terminal) seq.get(0)).text;
                        for (Production pnt : seq.subList(1, seq.size())) {
                            NonTerminal nt = (NonTerminal) pnt;
                            zn = (nt).refName;
                            env = parseEnv(nt);
                            type = parseType(nt);

                            l.add(new Judgement(env, zn, type));
                        }
                        list.add(new TypingRule(z, a, ari, l.toArray(array0)));
                    }
                }
            }
        }
        return list;
    }