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

51
LINES

< > BotCompany Repo | #1022817 // Attractor, DefaultAttractor, MatchAttractor [Include]

JavaX fragment (include)

1  
// not persistable
2  
sclass Attractor implements IAttractor, Runnable {
3  
  F1<S, Bool> tester;
4  
  Runnable action;
5  
  S input; // when matched
6  
7  
  *() {}
8  
  *(F1<S, Bool> *tester, Runnable *action) {}
9  
  *(Runnable *action) {}
10  
  
11  
  public bool matches(ExtS s) {
12  
    ret matches(s!);
13  
  }
14  
  
15  
  public bool matches(S s) {
16  
    ret isTrue(callF(tester, s));
17  
  }
18  
  
19  
  public void run {
20  
    callF(action);
21  
  }
22  
  
23  
  toString { ret standard_toString(this); }
24  
  
25  
  public bool matches_public(ExtS s) {
26  
    input = s!;
27  
    ret matches(s);
28  
  }
29  
  
30  
  public bool matches_public(S s) {
31  
    input = s;
32  
    ret matches(s);
33  
  }
34  
}
35  
36  
sclass DefaultAttractor > Attractor {
37  
  *() { this(null); }
38  
  *(Runnable *action) { tester = f1_true(); }
39  
}
40  
41  
sclass MatchAttractor > Attractor {
42  
  S pattern;
43  
  
44  
  *() {}
45  
  *(S *pattern) {}
46  
  *(S *pattern, Runnable *action) {}
47  
  
48  
  public bool matches(S s) {
49  
    ret matchX2(pattern, s);
50  
  }
51  
}

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: #1022817
Snippet name: Attractor, DefaultAttractor, MatchAttractor [Include]
Eternal ID of this version: #1022817/19
Text MD5: eafa1a241370e432b1fea74a21dad493
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-06-27 15:30:28
Source code size: 947 bytes / 51 lines
Pitched / IR pitched: No / No
Views / Downloads: 394 / 1045
Version history: 18 change(s)
Referenced in: [show references]