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

13
LINES

< > BotCompany Repo | #1022751 // tok_ifThenEnd - not nestable yet!

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

Libraryless. Click here for Pure Java version (2231L/14K).

// if condition then code end
svoid tok_ifThenEnd(LS tok) {
  int i = -1;
  while >= 0 (i = jfind(tok, i+1, "if <id>")) {
    int iThen = indexOf(tok, i, "then");
    if (iThen < 0) continue with print("No then for if");
    int iEnd = tok_findTokenSkippingCurlyBrackets(tok, iThen, "end");
    if (iEnd < 0) continue with print("No end for if");
    tokSet(tok, iEnd, "}");
    replaceTokens_reTok(tok, iThen-1, iThen+1, ") {");
    replaceTokens_reTok(tok, i, i+2, "if (");
  }
}

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: #1022751
Snippet name: tok_ifThenEnd - not nestable yet!
Eternal ID of this version: #1022751/4
Text MD5: 5e3642c715c8b5ae6a4d2006b988d0f5
Transpilation MD5: 51825dd1d9103fe59ea420e77a430f71
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-04-05 12:58:42
Source code size: 493 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 257 / 346
Version history: 3 change(s)
Referenced in: [show references]