scope gazelle_addHelperTablesToRules. sclass #Massager { LL helperTable; Map> helperIndex; *() {} *(LL *helperTable, Map> *helperIndex) {} SS get(SS map, LS tokC, LS tokI, RuleEngine2_MatchedRule matched) { if (map == null) null; //print("Massaging: " + map + " " + sfu(tokC) + " / " + sfu(tokI)); for (S t : codeTokens(matched.tokenize(matched.rule.out))) { //print("Checking: " + t); if (map.containsKey(t)) continue; Pair idx = helperIndex.get(t); if (idx == null) continue; //print("Found: " + t); for (S key, val : cloneMap(map)) { int idx2 = indexOfIC(helperTable.get(idx.a), key); if (idx2 < 0) continue; Pair idxVal = helperIndex.get(val); if (idxVal == null) continue; S out = _get(_get(helperTable, idxVal.a), idx.b); print("Massaged: " + t + " <-> " + key + " => " + out); mapPut(map, t, out); } } ret map; } } svoid gazelle_addHelperTablesToRules(RuleEngine2 engine) { new Matches m; for (final RuleEngine2.Rule r : engine.rules) { continue unless matchAny("use helper table mech list *", r.comments, m); LS entries = mL($1); continue if empty(entries); final LL helperTable = map tok_splitAtCommaOrDoubleArrow(entries); final Map> helperIndex = indexTwoDArrayIC(helperTable); r.addMapMassager(new Massager(helperTable, helperIndex)); } } end scope