!752 p { L tok = javaTok(loadSnippet("#1002166")); jreplace(tok, "string.Empty", quote("")); // classes are UPPER case! replaceToken(tok, "string", "String"); // ...and have different names. replaceToken(tok, "Dictionary", "Map"); // ...while methods are LOWER case. replaceToken(tok, "Split", "split"); replaceToken(tok, "Equals", "equals"); replaceToken(tok, "Add", "put"); replaceToken(tok, "ToLower", "toLowerCase"); // ...and have different names. replaceToken(tok, "ContainsKey", "containsKey"); // some syntax replaceToken(tok, "in", ":"); replaceToken(tok, "foreach", "for"); // split function takes a string in Java for (int i = 1; i+6 < l(tok); i += 2) if (eq(tok.get(i), "split") && eq(tok.get(i+2), "(") && tok.get(i+4).startsWith("'") && eq(tok.get(i+6), ")")) tok.set(i+4, charToStringLiteral(tok.get(i+4))); jreplace(tok, "[]++;", "$1.put($3, $1.get($3)+1);"); jreplace(tok, "new List", "new ArrayList"); jreplace(tok, ".Count", ".size()"); jreplace(tok, "[*]", ".get($2)"); jreplace(tok, "Uri.EscapeDataString", "urlencode"); print(join(tok)); } static S charToStringLiteral(S s) { ret "\"" + s.charAt(1) + "\""; // todo: special cases }