// Return value is index of semicolon/curly brace+1 static int tok_findEndOfStatement(L 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; }