/** * Gather sort information from a module. * Populates the close operators only for sorts which only have a single associative production. */ public static SortInfo fromModule(Module module) { Multimap<Sort, KLabel> joinOps = HashMultimap.create(); Collections.stream(module.productionsFor()).forEach(x -> { if (Collections.stream(x._2()).anyMatch(p -> p.att().contains("assoc") && Collections.stream(p.items()).filter(i -> i instanceof NonTerminal).count() == 2)) { joinOps.put(x._2().head().sort(), x._1()); } }); SortInfo info = new SortInfo(); joinOps.asMap().forEach((sort, labels) -> { info.closeOperators.put(sort, Iterators.getNext(labels.iterator(), null)); }); return info; } }