Libraryless. Click here for Pure Java version (304L/3K/9K).
// Syntax: stringFunc { s.trim() } !592 629 // auto-importer, standard function adder !723 // L<S> !680 // quicknew public class main { public static void main(String[] args) throws Exception { L<S> tok = javaTok(loadMainJava()); for (int i = 0; i < 100; i++) { int idx = findCodeTokens(tok, "stringfunc", "{"); if (idx < 0) break; int j = findEndOfBracketPart(tok, idx+2); tok.set(idx, "new StringFunc() {\n" + "public String get(String s) {\n" + "try { return "); tok.set(idx+2, ""); tok.set(j-1, "; } catch (Exception _e) {\n" + " throw _e instanceof RuntimeException ? (RuntimeException) _e : new RuntimeException(_e); } } }"); } // add interface to main class L<S> c = findMainClass(tok); if (join(c).indexOf("interface StringFunc") < 0) c.set(c.size()-2, "static interface StringFunc {\n" + " String get(String s);\n" + "}\n" + "}"); saveMainJava(join(tok)); } }
Began life as a copy of #721
download show line numbers debug dex old transpilations
Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, hxnwyiuffukg, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1000635 |
Snippet name: | "stringfunc {" (JavaX translator) |
Eternal ID of this version: | #1000635/1 |
Text MD5: | 711402167ab82a5432abe7145ab2204d |
Transpilation MD5: | c75062b65375830de197d6b47eea1943 |
Author: | stefan |
Category: | |
Type: | JavaX translator |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-09-30 18:39:07 |
Source code size: | 1079 bytes / 38 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 793 / 1954 |
Referenced in: | [show references] |