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<S> allowedVars; *() {} *(Set<S> *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
Began life as a copy of #1021872
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, whxojlpjdney
No comments. add comment
Snippet ID: | #1021981 |
Snippet name: | gazelle_addForbiddenBindingHelpers |
Eternal ID of this version: | #1021981/9 |
Text MD5: | 0b77a589627ed4e52cd663f372e4386f |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-03-16 22:25:22 |
Source code size: | 1575 bytes / 55 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 244 / 298 |
Version history: | 8 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |