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

23
LINES

< > BotCompany Repo | #1009077 // ctxProcessIf

JavaX fragment (include)

1  
static bool ctxProcessIf(L<S> tok) {
2  
  int i;
3  
  if ((i = jfind(tok, "if (")) == 1) {
4  
    int iEnd = findEndOfBracketPart(tok, i+2)-1;
5  
    S cond = join(subList(tok, i+4, iEnd-1));
6  
    bool yes = ctxEvalCondition(cond);
7  
    assertEquals("{", tok.get(iEnd+2));
8  
    int iEndYes = findEndOfBlock(tok, iEnd+2)-1;
9  
    S yesCode = join(subList(tok, iEnd+4, iEndYes-1));
10  
    int j = iEndYes+2;
11  
    S noCode = "";
12  
    if (eqGet(tok, iEndYes+2, "else")) {
13  
      int iNo = iEndYes+4;
14  
      assertEquals("{", tok.get(iNo));
15  
      int iEndNo = findEndOfBlock(tok, iNo)-1;
16  
      j = iEndNo+2;
17  
      noCode = join(subList(tok, iNo+2, iEndNo-1));
18  
    }
19  
    replaceTokens_reTok(tok, i, j, yes ? yesCode : noCode);
20  
    true;
21  
  }
22  
  false;
23  
}

Author comment

Began life as a copy of #1008911

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1009077
Snippet name: ctxProcessIf
Eternal ID of this version: #1009077/2
Text MD5: 61ebaf63d1100335a93442861bfd624d
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-07-01 19:14:18
Source code size: 743 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 467 / 500
Version history: 1 change(s)
Referenced in: [show references]