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

26
LINES

< > BotCompany Repo | #1015569 // tok_parseArgsList

JavaX fragment (include)

static L<S> tok_parseArgsList(S s) {
  ret tok_parseArgsList(javaTok(s));
}

static L<S> tok_parseArgsList(L<S> tok) {
  ret tok_parseArgsList(tok, getBracketMap(tok));
}
  
static L<S> tok_parseArgsList(L<S> tok, Map<Int> bracketMap) {
  int i = indexOfAny(tok, 0, "(", "{");
  if (i < 0) null;
  if (eq(get(tok, i), "{")) ret ll(); // e.g. void bla { ... }
  int argStart = (i += 2);
  new L<S> args;
  while (i < l(tok)-2 && neq(get(tok, i), ")")) {
    Int j = bracketMap.get(i);
    if (j != null) continue with i = j+2;
    if (eqGetOneOf(tok, i, ",")) {
      if (i > argStart) args.add(trimJoinSubList(tok, argStart, i));
      argStart = i+2;
    }
    i += 2;
  }
  if (i > argStart) args.add(trimJoinSubList(tok, argStart, i));
  ret args;
}

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: 422 / 488
Version history: 8 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1016801 - tok_parseArgsDeclList
#1019158 - tok_findArgs - returns CNC as IntRange
#1038295 - tok_parseInnerArgsList