// rewrite [=|with|to] // - a global version of "replace with" static SS tok_findRewrites(LS tok) { int i; SS rewrites = orderedMap(); while ((i = jfind(tok, "rewrite ", (_tok, nIdx) -> eqGetOneOf(_tok, nIdx+5, "with", "=", "to"))) >= 0) { S token = tok.get(i+2); int repStart = i+6; int repEnd = smartIndexOf(tok, repStart, "."); // TODO: allow expressions with brackets S replacement = joinSubList(tok, repStart, repEnd-1); rewrites.put(token, replacement); } ret rewrites; }