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

25
LINES

< > BotCompany Repo | #1018048 // ai_ruleAccessesInput

JavaX fragment (include)

1  
// OLD version
2  
sbool ai_ruleAccessesInput(S rule) {
3  
  L<S> tok = javaTokC(rule);
4  
  S t;
5  
  if (contains(tok, "ai_input")) true;
6  
  for i over tok:
7  
    if (eqGet(tok, i+1, "(") && isIdentifier(t = tok.get(i)))
8  
      if (eq(t, "i") || swic(t, "input") || ewic(t, "input")) true;
9  
  false;
10  
}
11  
12  
// NEW version
13  
sbool ai_ruleAccessesInput(IfThen rule) {
14  
  final new Flag flag;
15  
  nlLogic_visit(rule.in, voidfunc(O o) {
16  
    if (o cast Func) {
17  
      S t = o.name;
18  
      if (eqOneOf(t, "i", "phrase") || swic(t, "input") || ewic(t, "input"))
19  
        flag.raise();
20  
    }
21  
    if (o cast Exp)
22  
      if (jcontains(o.text(), "ai_input()")) flag.raise();
23  
  });
24  
  ret flag.isUp();
25  
}

Author comment

Began life as a copy of #1017925

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: #1018048
Snippet name: ai_ruleAccessesInput
Eternal ID of this version: #1018048/7
Text MD5: c6402d928d97ad77a6251285262edf37
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-23 15:09:14
Source code size: 685 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 358 / 392
Version history: 6 change(s)
Referenced in: [show references]