Libraryless. Compilation Failed (1665L/11K).
1 | !759 |
2 | |
3 | !include #1003145 // Puzzler for Bubblesort |
4 | !include #1003146 // HighLevel |
5 | |
6 | static int[] makeProgram(int startAddress) { |
7 | S code = new Puzzler("0 10 i j for for ifless swap").code(); |
8 | HighLevel h = new HighLevel(startAddress); |
9 | compile(code, h); |
10 | ret h.getProgram(); |
11 | } |
12 | |
13 | static void compile(S code, HighLevel h) { |
14 | new L stack; |
15 | new Matches m; |
16 | for (S line : toLinesFullTrim(code)) { |
17 | if (flexMatch("if * < * then", line)) { |
18 | stack.add(h.new IfLess(m.get(0), m.get(1))); |
19 | } else if (flexMatch("for * = * to *-1", line, m)) { |
20 | // push for |
21 | int var = h.getvar(m.get(0)); |
22 | h.set(var, m.get(1)); |
23 | stack.add(h.new ForIm(var, parseInt(m.get(2)))); |
24 | } else if (flexMatch("end", line)) { |
25 | O x = liftLast(stack); |
26 | call(x, "end"); |
27 | } else if (flexMatch("swap(*, *)", line)) { |
28 | h.swap(m.get(0), m.get(1)); |
29 | } else |
30 | fail("bad instruction: " + line); |
31 | } |
32 | } |
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1003147 |
Snippet name: | Bubblesort Puzzler - includes compiler |
Eternal ID of this version: | #1003147/1 |
Text MD5: | f2f68b715dcb50ab555ed83bec54a1c4 |
Transpilation MD5: | e5988fb6f3067a073390cf2c0bf9cc27 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-05-15 18:34:16 |
Source code size: | 946 bytes / 32 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 599 / 880 |
Referenced in: | [show references] |