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)

sclass FailedRule > RuleWithParams {
  L<Exp> satisfiedConditions;
  Exp remainingCondition;
  
  *() {}
  *(IfThen *rule, VarMatches *matches, Exp *remainingCondition) {}
  *(IfThen *rule, VarMatches *matches, L<Exp> *satisfiedConditions, Exp *remainingCondition) {}
}

srecord RuleWithParams(IfThen rule, VarMatches matches) {
  S ruleID() { ret rule.globalID; }
}

srecord IfThen(Exp in, Exp out) {
  S globalID;
  Set<S> options;
  S originalText;
  
  S text() {
    Collection<S> opt = options;
    if (nempty(globalID)) opt = concatLists(ll("id: " + globalID), opt);
    ret (nempty(opt) ? "[" + joinWithComma(opt) + "] " : "")
      + (in == null ? "" : in.text() + "\n  => ") + nlLogic_text(out);
  }
  
  toString { ret text(); }
}

abstract sclass Exp {
  abstract S text();
  toString { ret text(); }
}

static noToString record Func(S name, Exp arg) extends Exp {
  LS options;
  
  *(S *name, LS *options, Exp *arg) {}
  
  S text() {
    ret name
      + (empty(options) ? "" : "[" + joinWithComma(options) + "]")
      + "(" + arg.text() + ")";
  }
  
  S argText() { ret nlLogic_text(arg); }
}

static noToString record And(Exp a, Exp b) extends Exp {
  S text() {
    ret a.text() + "\n  && " + b.text();
  }
}

static noToString record ExpNot(Exp a) extends Exp {
  S text() {
    ret "!" + a.text();
  }
}

abstract sclass Literal extends Exp {}
static noToString record Sentence(L<S> tok) extends Literal { S text() { ret join(tok); } }
static noToString record Sentence2(S text) extends Literal { S text() { ret text; } }

static noToString record Eq(Exp left, Exp right) extends Exp {
  S text() {
    ret left.text() + " = " + right.text();
  }
}

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: 592 / 1188
Version history: 28 change(s)
Referenced in: #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)