static void tok_replaceWith(L<S> tok) { int i; while ping ((i = jfind(tok, "replace <id> with")) >= 0) { S token = tok.get(i+2); int repStart = i+6; int repEnd = repStart; // Find . with space or line break or EOF afterwards while ping (repEnd < l(tok) && !( eqGet(tok, repEnd, ".") && // end when there is a dot (nempty(get(tok, repEnd+1)) || repEnd == l(tok)-2))) // ...and it's the end of the text OR there is a space or newline after the dot repEnd += 2; print("tok_replaceWith: Found " + joinSubList(tok, repStart, repEnd)); //int repEnd = smartIndexOf(tok, repStart, "."); S replacement = joinSubList(tok, repStart, repEnd-1); clearTokens(tok, i, repEnd+1); print("Replacing " + token + " with " + replacement + "."); int end = findEndOfBlock(tok, repEnd)-1; for ping (int j = repEnd+2; j < end; j += 2) if (eq(tok.get(j), token)) tok.set(j, replacement); reTok(tok, i, end); } }
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment