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

36
LINES

< > BotCompany Repo | #1027653 // CruddieScript Spike (OK)

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

Download Jar. Libraryless. Click here for Pure Java version (7458L/52K).

!7

sclass CruddieScript {
  swappable void assume(S fact) {}
  S answer(S s) { null; }
  
  // make match function locally overridable
  swappable bool match(S pat, S s, Matches m) { ret match3(pat, s, m); }
  bool match(S pat, S s) { ret match(pat, s, null); }
}

sclass ICallYou > CruddieScript {
  swappable void setBotName(S name) {}
  swappable S getBotName() { null; }
  
  S answer(S s) null {
    new Matches m;
    
    if "I call you $name" { // fancy dollar var syntax with automatic declaration of S $name
      assume("\*$name*/ is a name");
      setBotName($name);
      ret "OK, my name is now \*$name*/";
    }
    
    if "What is your name"
      ret or2(getBotName(), "I don't know");
  }
}

p-exp {
  new ICallYou s;
  s.setBotName = lambda1 print;
  testFunctionValues(x -> s.answer((S) x),
    "I call you Horst",
    "OK, my name is now Horst");
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1027653
Snippet name: CruddieScript Spike (OK)
Eternal ID of this version: #1027653/17
Text MD5: 73bbdc0eb4a34c1295585311ad9dc9d5
Transpilation MD5: e01eea9277e4a8a1426ad110f48552e4
Author: stefan
Category: javax
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-03-29 20:34:08
Source code size: 907 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 287 / 989
Version history: 16 change(s)
Referenced in: [show references]