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

42
LINES

< > BotCompany Repo | #657 // Command processor (developing)

JavaX source code - run with: x30.jar

1  
!636
2  
!standard functions
3  
!multi-line strings
4  
5  
main {
6  
  psvm {
7  
    String cmd = "expand #655";
8  
    String[] words = cmd.split(" +");
9  
    System.out.println(words[0]);
10  
    System.out.println(words[1]);
11  
    String sentence = "You want to " + quote(words[0]) + " " + quote(words[1]) + ".";
12  
    System.out.println(sentence);
13  
    
14  
    Engine engine = new Engine();
15  
    engine.rules.add(new Rule(
16  
      [[You want to "expand" A.]],
17  
      [[You should run "#todo" with argument A.]]));
18  
  }
19  
  
20  
  static class Form {
21  
    String pattern;
22  
    List<String> elements = new ArrayList<String>();
23  
  }
24  
  
25  
  static Form parseForm(String s) {
26  
    return new Form();
27  
    // TODO
28  
  }
29  
  
30  
  static class Rule {
31  
    Form ante, post;
32  
    
33  
    Rule(String ante, String post) {
34  
      this.ante = parseForm(ante);
35  
      this.post = parseForm(post); 
36  
    }
37  
  }
38  
  
39  
  static class Engine {
40  
    List<Rule> rules = new ArrayList<Rule>();
41  
  }
42  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, qbtsjoyahagl, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #657
Snippet name: Command processor (developing)
Eternal ID of this version: #657/1
Text MD5: 427e9a4d0a07721c9875aaa1d88204e3
Author: stefan
Category:
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-07-06 18:30:39
Source code size: 950 bytes / 42 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 671 / 594
Referenced in: [show references]