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).

1  
!636
2  
!standard functions
3  
!class _javax 19
4  
5  
main {
6  
  psvm {
7  
    String snippetID = "#1000592";
8  
    boolean run = false;
9  
    
10  
    for args { // nifty new syntax provided by #680
11  
      if (arg.equals("run"))
12  
        run = true;
13  
      else if (isSnippetID(arg))
14  
        snippetID = arg;
15  
      else
16  
        System.out.println("Ignoring unknown argument " + arg);
17  
    }
18  
19  
    print "\nComment interpreter starting."
20  
    System.out.println("\nWorking on snippet: " + snippetID);
21  
    String text = loadSnippet(snippetID);
22  
    List<Comment> comments = getSnippetComments(snippetID);
23  
    for (Comment c : comments) {
24  
      System.out.println(c.user_name + " (" + c.user_id + ") says: " + c.text);
25  
      if (c.user_id == 1) {
26  
        Matcher m = Pattern.compile("entire subst (#\\d+)").matcher(c.text);
27  
        if (m.matches()) {
28  
          String newSnippetID = m.group(1);
29  
          System.out.println("Replacing with " + newSnippetID);
30  
          text = loadSnippet(newSnippetID);
31  
        }
32  
      }
33  
    }
34  
    System.out.println("Result:\n\n" + text + "\n");
35  
    
36  
    if (run) {
37  
      print "Running."
38  
      Class main = compileAndLoadMainClass(text);
39  
      System.out.println("Calling main method.\n");
40  
      call(main, "main", new Object[] {new String[0]});
41  
    }
42  
  }
43  
}

Author comment

Began life as a copy of #737

download  show line numbers  debug dex   

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

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: 623 / 556
Referenced in: [show references]

Formerly at http://tinybrain.de/1000594 & http://1000594.tinybrain.de