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

30
LINES

< > BotCompany Repo | #1001054 // Simple function call interpreter (developing)

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

Libraryless. Click here for Pure Java version (396L/4K/10K).

!747

m {
  static S cmd = "show(\"hello\");";
  
  p {
    go(); // to reuse variable name "args"
  }
  
  static void go() {
    L<S> tok = javaTok(cmd);
    S functionName = tok.get(1);
    new L<S> args;
    if (tok.size() > 7) {
      assertEquals("(", tok.get(3));
      int i = 5;
      while (i < tok.size() && !eq(tok.get(i), ")")) {
        args.add(unquote(tok.get(i)));
        i += 2;
        if (tok.get(i).equals(","))
          i += 2;
      }
    }
    call(main.class, functionName, args.toArray(new String[args.size()]));
  }
  
  static void show(S s) {
    print(s);
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1001054
Snippet name: Simple function call interpreter (developing)
Eternal ID of this version: #1001054/1
Text MD5: 24b411f23b25e6be70750fd30de6759e
Transpilation MD5: 0a76f98323f0291d8803e913a0c0ae20
Author: stefan
Category:
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-09-18 01:53:19
Source code size: 622 bytes / 30 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 548 / 539
Referenced in: [show references]