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

25
LINES

< > BotCompany Repo | #1027310 // philosophyBot_autoJava (backup v1 without arguments)

JavaX fragment (include)

1  
// doesn't support args yet
2  
// example use:
3  
//   java gazelle_guilds
4  
//
5  
//   proc {
6  
//     for $guild in gazelle_guilds():
7  
//       say (I am in guild $guild)
8  
//   }
9  
10  
svoid philosophyBot_autoJava(PhilosophyBot1 bot) {
11  
  bot.addFactPreprocessor(s -> {
12  
    LS tok = bot.mainTokenize(s);
13  
    if (countTokens(tok) == 2 && eq(firstToken(tok), "java")) {
14  
      S name = secondToken(tok);
15  
      if (!isIdentifier(name)) ret false;
16  
      print("Importing java function " + name);
17  
      if (!canCallAndMakeFunctionNamed(name))
18  
        ret false with print("Warning: Java function not found: " + name);
19  
      bot.addNativePredicate(name + "()",
20  
        () -> callAndMake(name));
21  
      true;
22  
    }
23  
    false;
24  
  });
25  
}

Author comment

Began life as a copy of #1025793

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027310
Snippet name: philosophyBot_autoJava (backup v1 without arguments)
Eternal ID of this version: #1027310/1
Text MD5: 25e8abf0a95a43fdaf38dead2f59bb8f
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-03-02 14:57:41
Source code size: 729 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 167 / 196
Referenced in: [show references]