Transpiled version (117L) is out of date.
1 | !636 // auto-import |
2 | !standard functions |
3 | !multi-line strings |
4 | !quicknew |
5 | |
6 | public class main { |
7 | static String prelude = [[ |
8 | public class main { |
9 | public static void main(String[] args) throws Exception { |
10 | System.out.println(calc()); |
11 | } |
12 | |
13 | public static Object calc() throws Exception { |
14 | ]]; |
15 | |
16 | static String postlude = [[ |
17 | } |
18 | } |
19 | ]]; |
20 | |
21 | public static void main(String[] args) throws IOException { |
22 | String code = loadTextFile("input/main.java", null); |
23 | if (code == null) |
24 | throw new RuntimeException("Nothing to do (no input/main.java)"); |
25 | code = prelude + code + postlude; |
26 | code = moveImportsUp(code); |
27 | saveTextFile("output/main.java", code); |
28 | } |
29 | |
30 | static String moveImportsUp(String s) { |
31 | List<String> l = toLines(s); |
32 | new List<String> x; |
33 | Pattern p = Pattern.compile("^\\s*import\\s"); |
34 | for (ListIterator<String> i = l.listIterator(); i.hasNext(); ) { |
35 | String line = i.next(); |
36 | if (p.matcher(line).find()) { |
37 | x.add(line); |
38 | i.remove(); |
39 | } |
40 | } |
41 | x.addAll(l); |
42 | return fromLines(x); |
43 | } |
44 | } |
Began life as a copy of #609
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: | #1000368 |
Snippet name: | !simplejava |
Eternal ID of this version: | #1000368/1 |
Text MD5: | 6cc1692b2baaaff2fb6b415f9f9c0f30 |
Author: | stefan |
Category: | |
Type: | JavaX translator |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-08-15 00:57:01 |
Source code size: | 1130 bytes / 44 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 799 / 935 |
Referenced in: | [show references] |