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

1  
!7
2  
3  
sclass CruddieScript {
4  
  swappable void assume(S fact) {}
5  
  S answer(S s) { null; }
6  
  
7  
  // make match function locally overridable
8  
  swappable bool match(S pat, S s, Matches m) { ret match3(pat, s, m); }
9  
  bool match(S pat, S s) { ret match(pat, s, null); }
10  
}
11  
12  
sclass ICallYou > CruddieScript {
13  
  swappable void setBotName(S name) {}
14  
  swappable S getBotName() { null; }
15  
  
16  
  S answer(S s) null {
17  
    new Matches m;
18  
    
19  
    if "I call you $name" { // fancy dollar var syntax with automatic declaration of S $name
20  
      assume("\*$name*/ is a name");
21  
      setBotName($name);
22  
      ret "OK, my name is now \*$name*/";
23  
    }
24  
    
25  
    if "What is your name"
26  
      ret or2(getBotName(), "I don't know");
27  
  }
28  
}
29  
30  
p-exp {
31  
  new ICallYou s;
32  
  s.setBotName = lambda1 print;
33  
  testFunctionValues(x -> s.answer((S) x),
34  
    "I call you Horst",
35  
    "OK, my name is now Horst");
36  
}

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: 178 / 702
Version history: 16 change(s)
Referenced in: [show references]