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

1  
sclass WordTokReplacer_es1 extends WordTokRule {
2  
  LS tokReplaced;
3  
  O[] outParams;
4  
  S requiredInputType;
5  
6  
  *(S sentence, S _vars, S replaced, O... outParams) {
7  
    super(dropLeadingSquareBracketStuff(sentence), asCISet(javaTokC(_vars)));
8  
    tokReplaced = wordTok_noBrackets(dropLeadingSquareBracketStuff(replaced));
9  
    this.outParams = paramsPlus(outParams, type := leadingSquareBracketStuff(replaced));
10  
    requiredInputType = leadingSquareBracketStuff(sentence);
11  
  }
12  
  
13  
  @Override bool preCheck(DynamicObject o) {
14  
    if (nempty(requiredInputType)) {
15  
      S type = getStringDyn type(o);
16  
      if (neqic(type, requiredInputType)) {
17  
        //printStackTrace("Bad type: " + type + " - " + extToString((Ext) o));
18  
        false;
19  
      }
20  
    }
21  
    true;
22  
  }
23  
  
24  
  run { emitOut(); }
25  
  
26  
  void emitOut {
27  
    emit(makeExt(join(replaceCodeTokensUsingMap_curly(tokReplaced, map)), outParams));
28  
  }
29  
}

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: 375 / 902
Version history: 11 change(s)
Referenced in: [show references]