// a cast B ? a.b : ... // => a instanceof B ? ((B) a).b : ... svoid tok_castQuestionDot(L tok) { for (int i : jfind_all_reversed(tok, " cast ?")) { int iEndOfType = indexOf(tok, i, "?"); int iColon = indexOf(tok, iEndOfType, ":"); S var = tok.get(i), type = joinSubList(tok, i+4, iEndOfType-1); S rawType = tok_dropTypeParameters(type); tok_insertCasts_reTok(tok, iEndOfType, iColon, var, type); tok.set(i+2, "instanceof"); } }