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

29
LINES

< > BotCompany Repo | #1023532 // WordTokReplacer_es1

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (4196L/26K).

sclass WordTokReplacer_es1 extends WordTokRule {
  LS tokReplaced;
  O[] outParams;
  S requiredInputType;

  *(S sentence, S _vars, S replaced, O... outParams) {
    super(dropLeadingSquareBracketStuff(sentence), asCISet(javaTokC(_vars)));
    tokReplaced = wordTok_noBrackets(dropLeadingSquareBracketStuff(replaced));
    this.outParams = paramsPlus(outParams, type := leadingSquareBracketStuff(replaced));
    requiredInputType = leadingSquareBracketStuff(sentence);
  }
  
  @Override bool preCheck(DynamicObject o) {
    if (nempty(requiredInputType)) {
      S type = getStringDyn type(o);
      if (neqic(type, requiredInputType)) {
        //printStackTrace("Bad type: " + type + " - " + extToString((Ext) o));
        false;
      }
    }
    true;
  }
  
  run { emitOut(); }
  
  void emitOut {
    emit(makeExt(join(replaceCodeTokensUsingMap_curly(tokReplaced, map)), outParams));
  }
}

Author comment

Began life as a copy of #1023530

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1023532
Snippet name: WordTokReplacer_es1
Eternal ID of this version: #1023532/12
Text MD5: 1728a88580ce85fa4676023e7a5243f1
Transpilation MD5: d74f98658e9292f16a848b4267fcf555
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-06-28 12:52:45
Source code size: 926 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 258 / 740
Version history: 11 change(s)
Referenced in: [show references]