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).

static L parseToFragmentsUsingWordTree(S input, MapSO wordTree) {
  LS tok = javaTok(input);
  new L out;
  int i = 1;
  Pair<IntRange, O> p;
  while ping ((p = findUsingWordTree(tok, wordTree, i)) != null) {
    int j = p.a.start;
    if (j > i)
      out.add(Fragment(joinSubList(tok, i, j-1)));
    out.add(p.b);
    i = max(p.a.end, i+2); // up to i+2 just for safety
  }
  if (i < l(tok)-1)
    out.add(Fragment(joinSubList(tok, i)));
  ret out;
}

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: 184 / 286
Version history: 4 change(s)
Referenced in: [show references]