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)

// It's rough but should work if you don't make anonymous classes inside the statement or something...
// Also won't work with "for"
// Return value is index of semicolon/curly brace+1
static int findEndOfStatement(L<S> tok, int i) {
  int j = i;
  
  // Is it a block?
  if (eq(get(tok, i), "{"))
    ret findEndOfBlock(tok, i)+1;
    
  // It's a regular statement.
  int n = l(tok);
  S t;
  while (j < n && !";".equals(t = tok.get(j)))
    if ("{".equals(t))
      j = findEndOfBlock(tok, j)+1;
    else
      j += 2;
  ret j+1;
}

Author comment

Began life as a copy of #1001046

download  show line numbers  debug dex   

Travelled to 10 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, tslmcundralx, tvejysmllsmz

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: 469 / 1393
Version history: 5 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1002453 & http://1002453.tinybrain.de