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

19
LINES

< > BotCompany Repo | #1021308 // ai_parseTokenRefNumbers

JavaX fragment (include)

1  
static Pair<LS, Map<Int>> ai_parseTokenRefNumbers(LS tok) {
2  
  tok = tok_combineSquareBrackets_keep(tok);
3  
  new LS out;
4  
  new Map<S, Int> refToToken;
5  
  new Map<Int> map;
6  
  for i over tok: {
7  
    S t = get(tok, i+1);
8  
    if (even(i) && isSquareBracketed(t)) {
9  
      t = deSquareBracket(t);
10  
      if (startsWith(t, "*"))
11  
        refToToken.put(dropFirst(t), l(out)-1);
12  
      else
13  
        mapPut(map, l(out)-1, refToToken.get(t));
14  
      ++i;
15  
    } else
16  
      out.add(tok.get(i));
17  
  }
18  
  ret pair(out, map);
19  
}

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: #1021308
Snippet name: ai_parseTokenRefNumbers
Eternal ID of this version: #1021308/7
Text MD5: 2f44da297e8451e07ff07549ebac984b
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-02-08 14:10:26
Source code size: 520 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 280 / 300
Version history: 6 change(s)
Referenced in: [show references]