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

12
LINES

< > BotCompany Repo | #1036306 // tok_ifdef

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

Libraryless. Click here for Pure Java version (10562L/59K).

// process ifdef x ... endifdef blocks
static void tok_ifdef(LS tok, IPred<S> isDefined) {
  // ifdef x or y
  jreplace_dyn(tok, "ifdef <id> or <id>", (_tok, cIdx) -> {
    S flag1 = tok.get(cIdx+2), flag2 = tok.get(cIdx+6);
    bool value = isDefined.get(flag1) || isDefined.get(flag2);
    //print("ifdef: " + flag1 + " | " + flag2 + " = " + value);
    ret "ifdef " + value;
  });
  
  tok_conditionals(tok, "ifdef", "endifdef", isDefined, true, false);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): elmgxqgtpvxh, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1036306
Snippet name: tok_ifdef
Eternal ID of this version: #1036306/3
Text MD5: 94af180afc93f1979bb568aa12ee2d0f
Transpilation MD5: 12ccb02191406494ec34804dd0452c8c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-11-15 18:19:06
Source code size: 469 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 62 / 98
Version history: 2 change(s)
Referenced in: [show references]