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)

// doesn't support args yet
// example use:
//   java gazelle_guilds
//
//   proc {
//     for $guild in gazelle_guilds():
//       say (I am in guild $guild)
//   }

svoid philosophyBot_autoJava(PhilosophyBot1 bot) {
  bot.addFactPreprocessor(s -> {
    LS tok = bot.mainTokenize(s);
    if (countTokens(tok) == 2 && eq(firstToken(tok), "java")) {
      S name = secondToken(tok);
      if (!isIdentifier(name)) ret false;
      print("Importing java function " + name);
      if (!canCallAndMakeFunctionNamed(name))
        ret false with print("Warning: Java function not found: " + name);
      bot.addNativePredicate(name + "()",
        () -> callAndMake(name));
      true;
    }
    false;
  });
}

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