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)

1  
svoid gazelle_gatherFulfillments(L<GazelleLine> lines, L<GazelleFulfillment> list_out, O... _) {
2  
  Int maxEntries = cast optPar maxEntries(_);
3  
  Flag cancel = cast optPar cancel(_);
4  
  bool debug = boolPar debug(_);
5  
  GazelleEvalContext ctx = cast optPar ctx(_);
6  
  if (ctx == null) ctx = dm_gazelle_stdEvalContext(dm_gazelle_rulesOnFacts());
7  
  else {
8  
    ctx = gazelle_cloneCtx(ctx);
9  
    ctx.engine.dropRulesWhere(r -> !gazelle_isRuleOnFacts(r.text, r.comments));
10  
  }
11  
  if (debug) print("Rules: " + l(ctx.engine.rules));
12  
  
13  
  for (GazelleLine line : lines) pcall {
14  
    L<GazelleTree> children = gazelle_getChildren(GazelleTree(ctx, line.text), _);
15  
    if (debug) print("line " + line + ": children: " + children);
16  
    for (GazelleTree t : gazelle_dropUnsatisfiedEntries(children)) pcall {
17  
      if (flagIsUp(cancel) || maxEntries != null && l(list_out) >= maxEntries) ret with print("Cancel");
18  
      GazelleFulfillment f = nu GazelleFulfillment(
19  
        line := t.parent.line,
20  
        varMap := struct(t.varMap()),
21  
        rule := t.ruleID(),
22  
        matchedRuleStruct := struct(t.mr),
23  
        context := "discord msg " + line.msgID);
24  
      if (debug) printStruct(f);
25  
      list_out.add(f);
26  
    }
27  
  }
28  
}

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: 399 / 412
Version history: 7 change(s)
Referenced in: [show references]