Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

29
LINES

< > BotCompany Repo | #1018145 // nlLogic_flexMatch_iterate

JavaX fragment (include)

sbool nlLogic_flexMatch_iterate_debug;

svoid nlLogic_flexMatch_iterate(S pat, S input, NLLogicChecker_v2.Matching m, Runnable onMatch, VarMatches oldMatches) {
  if (nlLogic_flexMatch_iterate_debug)
    print("nlLogic_flexMatch_iterate " + pat + " / " + input);
  L<S> tokPat = parse3_cachedPattern(pat), tokInput = parse3_cachedInput(input);
  // fail if crucial words not found (could be optimized more)
  new L<Int> varIndices;
  for (int i = 1; i < l(tokPat); i += 2) {
    S t = tokPat.get(i);
    if (isDollarVar(t))
      varIndices.add(i);
    else if (isIdentifier(t) && !cicAtOddPosition(tokInput, t)) {
      if (nlLogic_flexMatch_iterate_debug)
        print("Crucial word fail (" + t + "): " + pat + " / " + input);
      ret;
    }
  }
  if (nlLogic_flexMatch_iterate_debug)
    printStructs(+varIndices, +tokPat, +tokInput);
  LL<S> spreadInputs = ai_spreadCertainIndices(tokPat, tokInput, varIndices);
  for (L<S> tok : spreadInputs) {
    if (nlLogic_flexMatch_iterate_debug)
      print("Testing spread input: " + sfu(tok));
    SS newMatches = matchDollarVarsIC(pat, tok);
    if (newMatches != null && addMapToMapWithoutOverwritingIC(m.matches, newMatches))
      try { callF(onMatch); } finally { m.matches = oldMatches; }
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1018145
Snippet name: nlLogic_flexMatch_iterate
Eternal ID of this version: #1018145/9
Text MD5: 241dad2700b92e54ff70e491869c97dd
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-09-30 02:13:33
Source code size: 1278 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 411 / 463
Version history: 8 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1018147 - nlLogic_flexMatch_iterate_vbar
#1021059 - flexMatchIC_iterate [finds all solutions, seems to work now]