// true if successful // only call if there are more conditions sbool ai_ruleEngine2_matchStep(final RuleEngine2_MatchedRule matched, SS inputsByType, bool fillRemainingConditions, O... _) { bool debug = boolPar debug(_); RuleEngine2.Rule rule = matched.rule; TextAndType in = rule.insWithType.get(matched.iCond); S input = inputsByType.get(in.type); if (input == null) false; O inputMassager = get(rule.inputMassagers, matched.iCond); O checkerFunction = get(rule.checkerFunctions, matched.iCond); O matcher = get(rule.matchers, matched.iCond); LS tokC = null, tokI = null; SS map; if (inputMassager != null) { input = (S) callF(inputMassager, input); if (debug) print("Massaged input to: " + input); if (input == null) false; } if (checkerFunction != null) map = (SS) callF(checkerFunction, input); else { S cond = in.text; S tokenize = matched.tokenizationFunction; tokC = (LS) callAndMake(tokenize, cond); tokI = (LS) callAndMake(tokenize, input); if (debug) print("matchStep inputsByType=" + sfu(asTreeMap(inputsByType))); if (debug) print("matchStep in=" + in + ", iCond=" + matched.iCond + ", insWithType: " + rule.insWithType); if (debug) print("matchStep tokI/tokC: " + codeTokens(tokI) + " / " + codeTokens(tokC)); if (contains(cond, "{}")) tokI = ai_applyWordSplitPattern1(tokC, tokI); if (matcher != null) map = (SS) callF(matcher, tokC, tokI, matched); else map = zipCodeTokensToCIMap_strict_withoutEquals(tokC, tokI); } if (debug) print("matchStep for rule " + rule.globalID + " map: " + map); if (!gazelle_addMatch(matched, map, tokC, tokI, _)) { if (debug) print("addMatch failed - " + strWithIdentityHashCode(matched)); false; } matched.iCond++; // XXX - used to be at end of method if (debug) print("matchStep succeeded. " + matched); matched.matchedLines.add(pair(tokC, tokI)); if (fillRemainingConditions) { matched.remainingConditions = nullIfEmpty(map(dropFirst(matched.iCond, rule.in), func(S s) -> S { matched.applyMappingTo(s) })); matched.remainingConditionsWithType = nullIfEmpty(map(dropFirst(matched.iCond, rule.insWithType), func(TextAndType in) -> TextAndType { TextAndType(matched.applyMappingTo(in.text), in.type) })); } Map qualities = ai_ruleEngine2_mappingQualities(rule); for (S a, b : map) { mapPut(matched.mappingQuality, a, qualities.get(pair(a, b))); } if (debug) print("iCond now=" + matched.iCond + ", next input: " + get(matched.rule.insWithType, matched.iCond)); true; }