public static List<ProductionRule> toGrammarRules(Grammar g) {
        List<ProductionRule> list = new ArrayList<ProductionRule>();
        String a;
        String zn;
        for (Production p : g.ruleMap.values()) {
            String name = p.getProdName();
            if (name == null) {
                Utils.error(g, "Unsupported: grammars with auxiliary rules");
                continue;
            } else {
                String z = name;
                List<Production> seqList = new ArrayList<Production>();
                breakOrList(p, seqList);

                for (Production pp : seqList) {
                    int i = 0;
                    if (pp instanceof Terminal) {
                        a = ((Terminal) pp).text;
                        list.add(new ProductionRule(z, a, array1));
                    } else {
                    	List<String> l = new ArrayList<String>();
                        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 + (i++);
                        
                            l.add(zn);
                        }
                        list.add(new ProductionRule(z, a, l.toArray(array1)));
                    }
                }
            }
        }
        return list;
    }