sbool tok_doAsMethodName_strict = false; // Strict mode: // Sometimes you have to make sure to omit the space after "do" // do(...) // as opposed to // do (bla+bla).something(); while ...; << very unusual anyway // Non-strict mode: // do (bla+bla).something(); while ...; // is not possible anymore (but who does this?) // You can use spaces however you like static void tok_doAsMethodName(L tok) { if (!tok.contains("do")) ret; for (int i = 1; i+2 < l(tok); i += 2) { S next = tok.get(i+2), prev = get(tok, i-2); if (tok.get(i).equals("do") && eq(next, "(") && (!tok_doAsMethodName_strict || eq(prev, ".") || empty(tok.get(i+1)))) tok.set(i, "dO"); } }