1 | scope gazelle_addVarConvertersToRules. |
2 | |
3 | sclass #VarConverter { |
4 | S var1, var2; |
5 | O converter; // func(S) -> S |
6 | bool debug; |
7 | |
8 | *() {} |
9 | *(S *var1, S *var2, O *converter, bool *debug) {} |
10 | |
11 | SS get(SS map, LS tokC, LS tokI, RuleEngine2_MatchedRule matched) { |
12 | if (map == null) null; |
13 | S value = map.get(var1); |
14 | if (value == null) ret map; |
15 | S value2 = (S) callAndMake_orF1(converter, value); |
16 | if (debug) print("VarConverter: " + value + " => " + value2); |
17 | if (!strictPutIC(map, var2, value2)) null; |
18 | ret map; |
19 | } |
20 | } |
21 | |
22 | svoid gazelle_addVarConvertersToRules(RuleEngine2 engine, O... _) { |
23 | bool debug = boolPar debug(_) || boolPar varConverterDebug(_); |
24 | for (final RuleEngine2.Rule r : engine.rules) |
25 | for (Matches m : getJMatches_all("convert var * to * with *", r.comments)) |
26 | r.addMapMassager(new VarConverter($1, $2, $3, debug)); |
27 | } |
28 | |
29 | end scope |
Began life as a copy of #1021811
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: | #1021872 |
Snippet name: | gazelle_addVarConvertersToRules |
Eternal ID of this version: | #1021872/14 |
Text MD5: | 3a1bd6cd7f02156a316ff5f635bd0483 |
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-04 15:52:31 |
Source code size: | 897 bytes / 29 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 252 / 319 |
Version history: | 13 change(s) |
Referenced in: | [show references] |