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

1  
// if condition then code end
2  
svoid tok_ifThenEnd(LS tok) {
3  
  int i = -1;
4  
  while >= 0 (i = jfind(tok, i+1, "if <id>")) {
5  
    int iThen = indexOf(tok, i, "then");
6  
    if (iThen < 0) continue with print("No then for if");
7  
    int iEnd = tok_findTokenSkippingCurlyBrackets(tok, iThen, "end");
8  
    if (iEnd < 0) continue with print("No end for if");
9  
    tokSet(tok, iEnd, "}");
10  
    replaceTokens_reTok(tok, iThen-1, iThen+1, ") {");
11  
    replaceTokens_reTok(tok, i, i+2, "if (");
12  
  }
13  
}

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: 345 / 460
Version history: 3 change(s)
Referenced in: [show references]