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

13
LINES

< > BotCompany Repo | #1021798 // scanToEndOfInitializer2

JavaX fragment (include)

1  
// returns index of trailing N token
2  
static int scanToEndOfInitializer2(L<S> tok, int i) {
3  
  int level = 0;
4  
  while (i < l(tok)) {
5  
    S t = tok.get(i);
6  
    if (eqOneOf(t, "(", "{")) ++level;
7  
    else if (level > 0 && eqOneOf(t, ")", "}")) --level;
8  
    else if (level == 0 && eqOneOf(tok.get(i), ";", ",", ")", "}"))
9  
      ret i-1;
10  
    i++;
11  
  }
12  
  ret i;
13  
}

Author comment

Began life as a copy of #1002126

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: #1021798
Snippet name: scanToEndOfInitializer2
Eternal ID of this version: #1021798/2
Text MD5: 9ffebee10b2c272949a45bc9f4b65d27
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-02-27 13:37:18
Source code size: 367 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 345 / 377
Version history: 1 change(s)
Referenced in: [show references]