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

20
LINES

< > BotCompany Repo | #1002453 // findEndOfStatement (broken version, use tok_findEndOfStatement instead)

JavaX fragment (include)

1  
// It's rough but should work if you don't make anonymous classes inside the statement or something...
2  
// Also won't work with "for"
3  
// Return value is index of semicolon/curly brace+1
4  
static int findEndOfStatement(L<S> tok, int i) {
5  
  int j = i;
6  
  
7  
  // Is it a block?
8  
  if (eq(get(tok, i), "{"))
9  
    ret findEndOfBlock(tok, i)+1;
10  
    
11  
  // It's a regular statement.
12  
  int n = l(tok);
13  
  S t;
14  
  while (j < n && !";".equals(t = tok.get(j)))
15  
    if ("{".equals(t))
16  
      j = findEndOfBlock(tok, j)+1;
17  
    else
18  
      j += 2;
19  
  ret j+1;
20  
}

Author comment

Began life as a copy of #1001046

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: #1002453
Snippet name: findEndOfStatement (broken version, use tok_findEndOfStatement instead)
Eternal ID of this version: #1002453/6
Text MD5: 9465e7f4a2388a547dcb275e8d24ea5b
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-04 00:50:17
Source code size: 553 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 772 / 1732
Version history: 5 change(s)
Referenced in: [show references]