scope gazelle_addVarSplittersToRules. sclass #VarSplitter { S var; bool debug; *() {} *(S *var, bool *debug) {} SS get(SS map, LS tokC, LS tokI, RuleEngine2_MatchedRule matched) { if (map == null) null; S value = getOrKeep(map, curly(var)); LS tok1 = matched.tokenize(var); LS tok2 = matched.tokenize(uncurly(value)); if (debug) print("VarSplitter: " + tok1 + " / " + tok2); if (l(tok1) != l(tok2)) null; int oldSize = l(map); for (int i = 1; i < l(tok1); i += 2) if (!strictPutIC(map, tok1.get(i), tok2.get(i))) null; if (debug) print("VarSplitter done => " + map); matched.nPossibleVars = matched.nPossibleVars() + l(map)-oldSize; ret map; } } svoid gazelle_addVarSplittersToRules(RuleEngine2 engine, O... _) { new Matches m; bool debug = boolPar debug(_); for (final RuleEngine2.Rule r : engine.rules) { continue unless jmatchAny("split *", r.comments, m) && isQuoted(m.get(0)); S var = $1; if (debug) print("Made splitter for: " + var); r.addMapMassager(new VarSplitter(var, debug)); } } end scope
Began life as a copy of #1021688
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1021811 |
Snippet name: | gazelle_addVarSplittersToRules |
Eternal ID of this version: | #1021811/12 |
Text MD5: | a9b93e691bfaeae52d59ca6a5a4b966c |
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-02 18:47:46 |
Source code size: | 1131 bytes / 37 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 283 / 336 |
Version history: | 11 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1021865 - gazelle_addVarDiscriminators #1021872 - gazelle_addVarConvertersToRules |