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

68
LINES

< > BotCompany Repo | #1017547 // NL Logic Classes [Exp etc., Include]

JavaX fragment (include)

1  
sclass FailedRule > RuleWithParams {
2  
  L<Exp> satisfiedConditions;
3  
  Exp remainingCondition;
4  
  
5  
  *() {}
6  
  *(IfThen *rule, VarMatches *matches, Exp *remainingCondition) {}
7  
  *(IfThen *rule, VarMatches *matches, L<Exp> *satisfiedConditions, Exp *remainingCondition) {}
8  
}
9  
10  
srecord RuleWithParams(IfThen rule, VarMatches matches) {
11  
  S ruleID() { ret rule.globalID; }
12  
}
13  
14  
srecord IfThen(Exp in, Exp out) {
15  
  S globalID;
16  
  Set<S> options;
17  
  S originalText;
18  
  
19  
  S text() {
20  
    Collection<S> opt = options;
21  
    if (nempty(globalID)) opt = concatLists(ll("id: " + globalID), opt);
22  
    ret (nempty(opt) ? "[" + joinWithComma(opt) + "] " : "")
23  
      + (in == null ? "" : in.text() + "\n  => ") + nlLogic_text(out);
24  
  }
25  
  
26  
  toString { ret text(); }
27  
}
28  
29  
abstract sclass Exp {
30  
  abstract S text();
31  
  toString { ret text(); }
32  
}
33  
34  
static noToString record Func(S name, Exp arg) extends Exp {
35  
  LS options;
36  
  
37  
  *(S *name, LS *options, Exp *arg) {}
38  
  
39  
  S text() {
40  
    ret name
41  
      + (empty(options) ? "" : "[" + joinWithComma(options) + "]")
42  
      + "(" + arg.text() + ")";
43  
  }
44  
  
45  
  S argText() { ret nlLogic_text(arg); }
46  
}
47  
48  
static noToString record And(Exp a, Exp b) extends Exp {
49  
  S text() {
50  
    ret a.text() + "\n  && " + b.text();
51  
  }
52  
}
53  
54  
static noToString record ExpNot(Exp a) extends Exp {
55  
  S text() {
56  
    ret "!" + a.text();
57  
  }
58  
}
59  
60  
abstract sclass Literal extends Exp {}
61  
static noToString record Sentence(L<S> tok) extends Literal { S text() { ret join(tok); } }
62  
static noToString record Sentence2(S text) extends Literal { S text() { ret text; } }
63  
64  
static noToString record Eq(Exp left, Exp right) extends Exp {
65  
  S text() {
66  
    ret left.text() + " = " + right.text();
67  
  }
68  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1017547
Snippet name: NL Logic Classes [Exp etc., Include]
Eternal ID of this version: #1017547/29
Text MD5: 6701a8b0844ddb4c379fd71a9a7debe5
Author: stefan
Category: javax / networking
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-09-19 21:23:15
Source code size: 1737 bytes / 68 lines
Pitched / IR pitched: No / No
Views / Downloads: 593 / 1189
Version history: 28 change(s)
Referenced in: [show references]