scope gazelle_addForbiddenBindingHelpers. sclass #Blocker { S var, value; // value == null means don't change variable at all bool debug; *() {} *(S *var, S *value, bool *debug) {} SS get(SS map, LS tokC, LS tokI, RuleEngine2_MatchedRule matched) { if (map == null) null; if (value == null) { if (map.containsKey(var)) null; } else if (eqic(value, map.get(var))) null; ret map; } } sclass #TotalBlocker { SS get(SS map, LS tokC, LS tokI, RuleEngine2_MatchedRule matched) { if (nempty(map)) null; ret map; } } sclass #BlockAllExcept { Set allowedVars; *() {} *(Set *allowedVars) {} SS get(SS map, LS tokC, LS tokI, RuleEngine2_MatchedRule matched) { if (containsKeysExcept(map, allowedVars)) null; ret map; } } svoid gazelle_addForbiddenBindingHelpers(RuleEngine2 engine, O... _) { bool debug = boolPar debug(_) || boolPar forbiddenBindingsDebug(_); for (final RuleEngine2.Rule r : engine.rules) { for (Matches m : getJMatches_all("don't change * to *", r.comments)) r.addMapMassager(new Blocker($1, $2, debug)); for (Matches m : getJMatches_all("don't change *", r.comments)) if (isQuoted(m.get(0))) r.addMapMassager(new Blocker($1, null, debug)); if (cic(r.comments, "don't change anything")) r.addMapMassager(new TotalBlocker); S var = matchAny_firstGroup("only var is *", r.comments); if (var != null) r.addMapMassager(new BlockAllExcept(litciset(var))); } } end scope