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

27
LINES

< > BotCompany Repo | #1017549 // nlLogic_parseRule

JavaX fragment (include)

1  
static IfThen nlLogic_parseRule(S s) {
2  
  new IfThen rule;
3  
  rule.originalText = s;
4  
  L<S> tok = javaTokPlusBrackets2(s);
5  
  if (isSquareBracketed(get(tok, 1))) {
6  
    L<S> tokOptions = javaTokPlusBrackets2(deSquareBracket(get(tok, 1)));
7  
    new Matches m;
8  
    for (S option : tok_splitAtComma(tokOptions)) {
9  
      if (startsWith_trim(option, "id: ", m))
10  
        rule.globalID = m.rest();
11  
      else
12  
        rule.options = linkedHashSet_addWithAutoInit(rule.options, option);
13  
    }
14  
    tok = dropFirst(2, tok);
15  
  }
16  
  
17  
  L<S> l = splitAtDoubleArrow(tok);
18  
  if (l(l) > 2 || l(l) == 0) null;
19  
  rule.out = nlLogic_parseExpression(last(l));
20  
  rule.in = nlLogic_parseExpression(nextToLast(l));
21  
  
22  
  if (rule.globalID == null)
23  
    //rule.globalID = aGlobalID();
24  
    rule.globalID = textMD5ToGlobalID(str(rule));
25  
    
26  
  ret rule;
27  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1017549
Snippet name: nlLogic_parseRule
Eternal ID of this version: #1017549/11
Text MD5: ac460622b327823edc8abfad46116e14
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-08-23 15:12:37
Source code size: 846 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 463 / 564
Version history: 10 change(s)
Referenced in: [show references]