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

26
LINES

< > BotCompany Repo | #1015569 // tok_parseArgsList

JavaX fragment (include)

1  
static L<S> tok_parseArgsList(S s) {
2  
  ret tok_parseArgsList(javaTok(s));
3  
}
4  
5  
static L<S> tok_parseArgsList(L<S> tok) {
6  
  ret tok_parseArgsList(tok, getBracketMap(tok));
7  
}
8  
  
9  
static L<S> tok_parseArgsList(L<S> tok, Map<Int> bracketMap) {
10  
  int i = indexOfAny(tok, 0, "(", "{");
11  
  if (i < 0) null;
12  
  if (eq(get(tok, i), "{")) ret ll(); // e.g. void bla { ... }
13  
  int argStart = (i += 2);
14  
  new L<S> args;
15  
  while (i < l(tok)-2 && neq(get(tok, i), ")")) {
16  
    Int j = bracketMap.get(i);
17  
    if (j != null) continue with i = j+2;
18  
    if (eqGetOneOf(tok, i, ",")) {
19  
      if (i > argStart) args.add(trimJoinSubList(tok, argStart, i));
20  
      argStart = i+2;
21  
    }
22  
    i += 2;
23  
  }
24  
  if (i > argStart) args.add(trimJoinSubList(tok, argStart, i));
25  
  ret args;
26  
}

Author comment

Began life as a copy of #1012494

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1015569
Snippet name: tok_parseArgsList
Eternal ID of this version: #1015569/9
Text MD5: fa5c01f80b3a3857003567bf2eac2f04
Author: stefan
Category: javax / parsing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-07-02 18:39:25
Source code size: 777 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 421 / 488
Version history: 8 change(s)
Referenced in: [show references]