Libraryless. Click here for Pure Java version (2563L/16K).
// Return value is index of semicolon/curly brace+1 static int tok_findEndOfStatement(L<S> tok, int i) { // Is it a block? if (eq(get(tok, i), "{")) ret findEndOfBlock(tok, i); // It's a regular statement. Special handling of "for" and "if" int j = i; bool special; while (j < l(tok) && neq(tok.get(j), ";")) { S t = get(tok, j); if (eqOneOf(t, "for", "if")) set special; if (eqOneOf(t, "{", "(")) { j = findEndOfBracketPart(tok, j)+1; if (special && eq(t, "{")) ret j-1; } else j += 2; } ret j+1; }
Began life as a copy of #1002453
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: | #1017567 |
Snippet name: | tok_findEndOfStatement (works, but might have trouble with for + block) |
Eternal ID of this version: | #1017567/10 |
Text MD5: | 8778470445b3af424c4e072959740ede |
Transpilation MD5: | 40357101b47659031bccf11aa2aaa087 |
Author: | stefan |
Category: | javax / parsing |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-12-18 18:55:32 |
Source code size: | 577 bytes / 20 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 536 / 638 |
Version history: | 9 change(s) |
Referenced in: | [show references] |