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

16
LINES

< > BotCompany Repo | #1028741 // parseToFragmentsUsingWordTree

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2788L/18K).

1  
static L parseToFragmentsUsingWordTree(S input, MapSO wordTree) {
2  
  LS tok = javaTok(input);
3  
  new L out;
4  
  int i = 1;
5  
  Pair<IntRange, O> p;
6  
  while ping ((p = findUsingWordTree(tok, wordTree, i)) != null) {
7  
    int j = p.a.start;
8  
    if (j > i)
9  
      out.add(Fragment(joinSubList(tok, i, j-1)));
10  
    out.add(p.b);
11  
    i = max(p.a.end, i+2); // up to i+2 just for safety
12  
  }
13  
  if (i < l(tok)-1)
14  
    out.add(Fragment(joinSubList(tok, i)));
15  
  ret out;
16  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028741
Snippet name: parseToFragmentsUsingWordTree
Eternal ID of this version: #1028741/5
Text MD5: ad697a38b43e1581c593ce12bf909415
Transpilation MD5: 21def42e4b137324f09a2ee567ce8605
Author: stefan
Category: javax / parsing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-06 21:07:31
Source code size: 467 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 185 / 288
Version history: 4 change(s)
Referenced in: [show references]