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

23
LINES

< > BotCompany Repo | #1009077 // ctxProcessIf

JavaX fragment (include)

static bool ctxProcessIf(L<S> tok) {
  int i;
  if ((i = jfind(tok, "if (")) == 1) {
    int iEnd = findEndOfBracketPart(tok, i+2)-1;
    S cond = join(subList(tok, i+4, iEnd-1));
    bool yes = ctxEvalCondition(cond);
    assertEquals("{", tok.get(iEnd+2));
    int iEndYes = findEndOfBlock(tok, iEnd+2)-1;
    S yesCode = join(subList(tok, iEnd+4, iEndYes-1));
    int j = iEndYes+2;
    S noCode = "";
    if (eqGet(tok, iEndYes+2, "else")) {
      int iNo = iEndYes+4;
      assertEquals("{", tok.get(iNo));
      int iEndNo = findEndOfBlock(tok, iNo)-1;
      j = iEndNo+2;
      noCode = join(subList(tok, iNo+2, iEndNo-1));
    }
    replaceTokens_reTok(tok, i, j, yes ? yesCode : noCode);
    true;
  }
  false;
}

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: 465 / 497
Version history: 1 change(s)
Referenced in: [show references]