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

43
LINES

< > BotCompany Repo | #1000594 // Comment interpreter (developing)

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

Libraryless. Click here for Pure Java version (2263L/16K/51K).

!636
!standard functions
!class _javax 19

main {
  psvm {
    String snippetID = "#1000592";
    boolean run = false;
    
    for args { // nifty new syntax provided by #680
      if (arg.equals("run"))
        run = true;
      else if (isSnippetID(arg))
        snippetID = arg;
      else
        System.out.println("Ignoring unknown argument " + arg);
    }

    print "\nComment interpreter starting."
    System.out.println("\nWorking on snippet: " + snippetID);
    String text = loadSnippet(snippetID);
    List<Comment> comments = getSnippetComments(snippetID);
    for (Comment c : comments) {
      System.out.println(c.user_name + " (" + c.user_id + ") says: " + c.text);
      if (c.user_id == 1) {
        Matcher m = Pattern.compile("entire subst (#\\d+)").matcher(c.text);
        if (m.matches()) {
          String newSnippetID = m.group(1);
          System.out.println("Replacing with " + newSnippetID);
          text = loadSnippet(newSnippetID);
        }
      }
    }
    System.out.println("Result:\n\n" + text + "\n");
    
    if (run) {
      print "Running."
      Class main = compileAndLoadMainClass(text);
      System.out.println("Calling main method.\n");
      call(main, "main", new Object[] {new String[0]});
    }
  }
}

Author comment

Began life as a copy of #737

download  show line numbers  debug dex  old transpilations   

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

Comments [hide]

ID Author/Program Comment Date
508 #1000610 (pitcher) 2015-08-18 18:45:01
507 #1000604 (pitcher) 2015-08-20 15:28:24

add comment

Snippet ID: #1000594
Snippet name: Comment interpreter (developing)
Eternal ID of this version: #1000594/1
Text MD5: 6b4f0f0652b5ca264673f5e4c6fdea80
Transpilation MD5: 99846cc702b569c615fce422c8e6596b
Author: stefan
Category:
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-08-18 18:45:01
Source code size: 1301 bytes / 43 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 836 / 828
Referenced in: [show references]