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

24
LINES

< > BotCompany Repo | #1026296 - tok_tildeCalls - reflective calls with ~.

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

Libraryless. Click here for Pure Java version (2816L/18K).

svoid tok_tildeCalls(LS tok) {
  int iTilde;
  while ((iTilde = jfind(tok, "~.<id>(")) >= 0) {
    int iStart = tok_findBeginningOfJavaXTerm(tok, iTilde-2);
    S fname = tok.get(iTilde+4);
    tokPrepend(tok, iStart, "call(");
    replaceTokens(tok, iTilde, iTilde+8, ", " + quote(fname)
      + (eqGet(tok, iTilde+8, ")") ? "" : ", "));
    reTok(tok, iStart, iTilde+8);
  }
  
  // with type
  while ((iTilde = jfind(tok, "~.<id> <id>(")) >= 0) {
    int iStart = tok_findBeginningOfJavaXTerm(tok, iTilde-2);
    S type = get(tok, iTilde+4);
    int iFname = iTilde+6;
    S fname = tok.get(iFname);
    // TODO: brackets around the whole thing
    tokPrepend(tok, iStart, "(" + type + ") call(");
    replaceTokens(tok, iTilde, iFname+4, ", " + quote(fname)
      + (eqGet(tok, iFname+4, ")") ? "" : ", "));
    reTok(tok, iStart, iFname+4);
  }
}

download  show line numbers  debug dex   

Travelled to 2 computer(s): mqqgnosmbjvj, tvejysmllsmz

No comments. add comment

Snippet ID: #1026296
Snippet name: tok_tildeCalls - reflective calls with ~.
Eternal ID of this version: #1026296/7
Text MD5: df270c9812308092e21857386b2db55d
Transpilation MD5: 84da9ea0fad2c0ee0fabc6d27106ae6a
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-12-13 15:09:52
Source code size: 874 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 21 / 55
Version history: 6 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1026296 & http://1026296.tinybrain.de