1 | svoid dm_gazelle_matchStatements(L<GazelleTree> l, O... _) {
|
2 | for (GazelleTree t : l) |
3 | if (t.rule() != null) {
|
4 | RuleEngine2_MatchedRule mr = t.mr; |
5 | LS in = t.rule().in; |
6 | int iCond = t.mr.iCond; |
7 | print("matchStatements: iCond=" + iCond + " in " + in);
|
8 | if (l(in) > iCond) {
|
9 | LS conditions = dropFirst(iCond, in); |
10 | print("Remaining conditions for " + t.ruleID() + " with " + t.mr.map + ": " + conditions);
|
11 | new Matches m; |
12 | if (!matchAny("in " + (iCond+1) + " = statement *", t.rule().comments, m))
|
13 | continue with print("Unwired condition");
|
14 | S subRuleID = $1; |
15 | print("Found subrule: " + subRuleID);
|
16 | L fulfillments = dm_gazelle_fulfillmentsForRule(subRuleID); |
17 | print("Have fulfillments:");
|
18 | for (O f : fulfillments) {
|
19 | SS varMap = asCIMap(safeUnstructMap(getString varMap(f))); |
20 | printIndent(sfu(varMap)); |
21 | |
22 | // self-vars hack to fix John Doe problem |
23 | bool selfVarsFix = boolPar selfVarsFix(_, true); |
24 | if (selfVarsFix) {
|
25 | S cond = first(conditions); |
26 | for (S x : identifiersOnly(codeTokens(mr.tokenize(cond)))) |
27 | if (!varMap.containsKey(x)) {
|
28 | print("Self-linking " + x);
|
29 | varMap.put(x, x); |
30 | } |
31 | } |
32 | |
33 | print("Original map: " + t.mr.map);
|
34 | SS newMap = mergeMapsStrictlyIC(asCIMap(t.mr.map), varMap); |
35 | if (newMap == null) |
36 | continue with printIndent("Can't merge maps");
|
37 | printIndent("Maps merged! => " + sfu(newMap));
|
38 | t.mr.map = newMap; |
39 | t.mr.iCond++; |
40 | t.mr.remainingConditions = dropFirst(t.mr.remainingConditions); // XX: also should rewrite with new vars |
41 | t.mr.remainingConditionsWithType = dropFirst(t.mr.remainingConditionsWithType); |
42 | t.mr.out = null; |
43 | t.line = t.mr.outText(); |
44 | print("Rewrote " + t.mr.rule.out + " to: " + t.line);
|
45 | break; |
46 | } |
47 | } |
48 | } |
49 | } |
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: | #1021772 |
| Snippet name: | dm_gazelle_matchStatements |
| Eternal ID of this version: | #1021772/3 |
| Text MD5: | 19f8ef2d863d2dd5588ba00905e50119 |
| Author: | stefan |
| Category: | javax / a.i. |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2019-02-26 13:10:31 |
| Source code size: | 2083 bytes / 49 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 487 / 548 |
| Version history: | 2 change(s) |
| Referenced in: | [show references] |