static Pair ai_groupUsingProductionsAndReturnGroups(S s, AI_BottomUpParser1 p) { p.splitSplittables = false; p.parse(javaTokNPunctuation(s)); new LS groups; for (AI_BottomUpParser1.Word g : p.groups()) { int i = g.wordFrom*2+1, j = g.wordTo*2-1; S pre = get(p.cnc, i-1), post = get(p.cnc, j+1); //print("pre=" + pre + ", post=" + post); groups.add(joinSubList(p.cnc, i, j+1)); if (endsWith(pre, "{") && startsWith(post, "}")) continue; tokPrepend(p.cnc, i, "{"); tokAppend(p.cnc, j, "}"); } ret pair(join(p.cnc), groups); }