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

19
LINES

< > BotCompany Repo | #1022877 // pAttractor_allMatches3 - accepts multiple attractors, returns cloned attractors

JavaX fragment (include)

1  
static L<PartialAttractor> pAttractor_allMatches3(Collection<PartialAttractor> attractors, LS tok) {
2  
  int i = 0;
3  
  new L<PartialAttractor> out;
4  
  while (licensed() && i < l(tok)) {
5  
    new Lowest<PartialAttractor> best;
6  
    for (PartialAttractor a : attractors) {
7  
      a.tok = subList(tok, i);
8  
      if (a.find()) {
9  
        if (a.matchedRange.end < 2)
10  
          continue with print("Bad attractor (empty match): " + a);
11  
        best.put(shallowClone(a), a.matchedRange.start);
12  
      }
13  
    }
14  
    if (!best.has()) break; // no more matches
15  
    out.add(best!);
16  
    i += best->matchedRange.end & ~1; // go to next N token
17  
  }
18  
  ret out;
19  
}

Author comment

Began life as a copy of #1022875

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: #1022877
Snippet name: pAttractor_allMatches3 - accepts multiple attractors, returns cloned attractors
Eternal ID of this version: #1022877/3
Text MD5: 2cc05d720eed633485016430ce90a40a
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-04-12 17:06:45
Source code size: 654 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 244 / 284
Version history: 2 change(s)
Referenced in: [show references]