svoid tok_questionDot(LS tok) { jreplace_dyn(tok, "->?.", -> { S var = makeVar(); ret var + " -> " + var + "?."; }); jreplace(tok, "if ( ?. ?.")) >= 0) { S var = tok.get(i); bool isExpression = eqGetOneOf(tok, i-2, "ret", "return", ",", "=", "(", "?", "+", ">"); // too few if (!isExpression) { int j = tok_findEndOfStatement(tok, i)-1; tokAppend_reTok(tok, j, " }"); tokReplace_reTok(tok, i, i+6, "{ if (\*var*/ != null) \*var*/."); } else { S expr = "\*var*/ == null ? null : \*var*/."; bool needBrackets = eqGet(tok, i-2, "+"); if (needBrackets) { expr = "(" + expr; int j = tok_endOfExpression(tok, i)-1; tokPrepend_reTok(tok, j, ")"); } tokReplace_reTok(tok, i, i+6, expr); } } jreplace_dyn(tok, "()?.", func(LS tok, int i) -> S { int iQ = indexOf(tok, i, "?"); S expr = joinSubList(tok, i, iQ-1); bool isExpression = eqGetOneOf(tok, i-2, "ret", "return", ",", "=", "(", "?"); // too few S var = makeVar(); if (!isExpression) { int j = tok_findEndOfStatement(tok, i)-1; tokAppend_reTok(tok, j, " }"); ret "{ var \*var*/ = \*expr*/; if (\*var*/ != null) \*var*/."; } else { // experimental int j = tok_findEndOfExpression(tok, i)-1; tokAppend_reTok(tok, j, ")"); ret "rCallF(\*expr*/, \*var*/ -> \*var*/ == null ?: \*var*/."; } }); }