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

28
LINES

< > BotCompany Repo | #1021760 // gazelle_gatherFulfillments - scan input lines for fulfillments

JavaX fragment (include)

svoid gazelle_gatherFulfillments(L<GazelleLine> lines, L<GazelleFulfillment> list_out, O... _) {
  Int maxEntries = cast optPar maxEntries(_);
  Flag cancel = cast optPar cancel(_);
  bool debug = boolPar debug(_);
  GazelleEvalContext ctx = cast optPar ctx(_);
  if (ctx == null) ctx = dm_gazelle_stdEvalContext(dm_gazelle_rulesOnFacts());
  else {
    ctx = gazelle_cloneCtx(ctx);
    ctx.engine.dropRulesWhere(r -> !gazelle_isRuleOnFacts(r.text, r.comments));
  }
  if (debug) print("Rules: " + l(ctx.engine.rules));
  
  for (GazelleLine line : lines) pcall {
    L<GazelleTree> children = gazelle_getChildren(GazelleTree(ctx, line.text), _);
    if (debug) print("line " + line + ": children: " + children);
    for (GazelleTree t : gazelle_dropUnsatisfiedEntries(children)) pcall {
      if (flagIsUp(cancel) || maxEntries != null && l(list_out) >= maxEntries) ret with print("Cancel");
      GazelleFulfillment f = nu GazelleFulfillment(
        line := t.parent.line,
        varMap := struct(t.varMap()),
        rule := t.ruleID(),
        matchedRuleStruct := struct(t.mr),
        context := "discord msg " + line.msgID);
      if (debug) printStruct(f);
      list_out.add(f);
    }
  }
}

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: #1021760
Snippet name: gazelle_gatherFulfillments - scan input lines for fulfillments
Eternal ID of this version: #1021760/8
Text MD5: b6ac0bf23d3100620fcce0d4846060fe
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-12 17:59:22
Source code size: 1228 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 400 / 412
Version history: 7 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)