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

14
LINES

< > BotCompany Repo | #1023410 - tok_expandVarCopies (+var)

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

Libraryless. Click here for Pure Java version (1763L/12K).

// +var => "var", +var
// i.e. pattern "+<id>"
svoid tok_expandVarCopies(L<S> tok) {
  bool change = false;
  for (int i = 3; i+2 < l(tok); i += 2) {
    if (!eq(tok.get(i), "+")) continue;
    if (!eqOneOf(tok.get(i-2), "(", ",", "{")) continue;
    S s = tok.get(i+2);
    if (!isIdentifier(s)) continue;
    tok.set(i, quote(s) + ", ");
    change = true;
  }
  if (change) reTok(tok);
}

download  show line numbers  debug dex   

Travelled to 5 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pzhvpgtvlbxg, tvejysmllsmz

No comments. add comment

Snippet ID: #1023410
Snippet name: tok_expandVarCopies (+var)
Eternal ID of this version: #1023410/1
Text MD5: 826b935536da6f58616894315392ad14
Transpilation MD5: ea77e096867c9544347c423a0523955d
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-06-17 22:53:00
Source code size: 403 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 68 / 79
Referenced in: [show references]

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