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

20
LINES

< > BotCompany Repo | #1019158 // tok_findArgs - returns CNC as IntRange

JavaX fragment (include)

static IntRange tok_findArgs(LS tok) {
  ret tok_findArgs(tok, getBracketMap(tok));
}
  
static IntRange tok_findArgs(LS tok, Map<Int> bracketMap) {
  ret tok_findArgs(tok, 0, bracketMap);
}

static IntRange tok_findArgs(LS tok, int i, Map<Int> bracketMap) {
  i = indexOfAny(tok, i, "(", "{");
  if (i < 0) null;
  if (eq(get(tok, i), "{")) null;
  int start = (i += 2);
  while (i < l(tok)-2 && neq(get(tok, i), ")")) {
    Int j = bracketMap.get(i);
    if (j != null) continue with i = j+2;
    i += 2;
  }
  ret intRange(start-1, i);
}

Author comment

Began life as a copy of #1015569

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1019158
Snippet name: tok_findArgs - returns CNC as IntRange
Eternal ID of this version: #1019158/6
Text MD5: ebf95dc4c67bd1c911be841b5f95df57
Author: stefan
Category: javax / parsing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-09 20:45:06
Source code size: 559 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 254 / 304
Version history: 5 change(s)
Referenced in: [show references]