svoid dm_gazelle_matchStatements(L<GazelleTree> l, O... _) { for (GazelleTree t : l) if (t.rule() != null) { RuleEngine2_MatchedRule mr = t.mr; LS in = t.rule().in; int iCond = t.mr.iCond; print("matchStatements: iCond=" + iCond + " in " + in); if (l(in) > iCond) { LS conditions = dropFirst(iCond, in); print("Remaining conditions for " + t.ruleID() + " with " + t.mr.map + ": " + conditions); new Matches m; if (!matchAny("in " + (iCond+1) + " = statement *", t.rule().comments, m)) continue with print("Unwired condition"); S subRuleID = $1; print("Found subrule: " + subRuleID); L fulfillments = dm_gazelle_fulfillmentsForRule(subRuleID); print("Have fulfillments:"); for (O f : fulfillments) { SS varMap = asCIMap(safeUnstructMap(getString varMap(f))); printIndent(sfu(varMap)); // self-vars hack to fix John Doe problem bool selfVarsFix = boolPar selfVarsFix(_, true); if (selfVarsFix) { S cond = first(conditions); for (S x : identifiersOnly(codeTokens(mr.tokenize(cond)))) if (!varMap.containsKey(x)) { print("Self-linking " + x); varMap.put(x, x); } } print("Original map: " + t.mr.map); SS newMap = mergeMapsStrictlyIC(asCIMap(t.mr.map), varMap); if (newMap == null) continue with printIndent("Can't merge maps"); printIndent("Maps merged! => " + sfu(newMap)); t.mr.map = newMap; t.mr.iCond++; t.mr.remainingConditions = dropFirst(t.mr.remainingConditions); // XX: also should rewrite with new vars t.mr.remainingConditionsWithType = dropFirst(t.mr.remainingConditionsWithType); t.mr.out = null; t.line = t.mr.outText(); print("Rewrote " + t.mr.rule.out + " to: " + t.line); break; } } } }
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: | 273 / 317 |
Version history: | 2 change(s) |
Referenced in: | [show references] |