Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

32
LINES

< > BotCompany Repo | #1003147 // Bubblesort Puzzler - includes compiler

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Compilation Failed (1665L/11K).

!759

!include #1003145 // Puzzler for Bubblesort
!include #1003146 // HighLevel

static int[] makeProgram(int startAddress) {
  S code = new Puzzler("0 10 i j for for ifless swap").code();
  HighLevel h = new HighLevel(startAddress);
  compile(code, h);
  ret h.getProgram();
}

static void compile(S code, HighLevel h) {
  new L stack;
  new Matches m;
  for (S line : toLinesFullTrim(code)) {
    if (flexMatch("if * < * then", line)) {
      stack.add(h.new IfLess(m.get(0), m.get(1)));
    } else if (flexMatch("for * = * to *-1", line, m)) {
      // push for
      int var = h.getvar(m.get(0));
      h.set(var, m.get(1));
      stack.add(h.new ForIm(var, parseInt(m.get(2))));
    } else if (flexMatch("end", line)) {
      O x = liftLast(stack);
      call(x, "end");
    } else if (flexMatch("swap(*, *)", line)) {
      h.swap(m.get(0), m.get(1));
    } else
      fail("bad instruction: " + line);
  }
}

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: 600 / 880
Referenced in: #1003138 - GenOpt 1 (Sorting)
#1003158 - Bubblesort Puzzler using Lua