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

18
LINES

< > BotCompany Repo | #1021797 // tok_scanTypeBackwards (also jumps over package names)

JavaX fragment (include)

// i = last C token of type
// returns first C token of type
static int tok_scanTypeBackwards(LS tok, int i) {
  if (i < 0) ret i;
  int level = 0;
  while (i > 0) {
    S t = tok.get(i);
    if (isIdentifier(t) && level == 0) {
      while (eqGet(tok, i-2, ".") && isIdentifier(get(tok, i-4)))
        i -= 4;
      ret i;
    }
    if (eq(t, ">")) ++level;
    else if (eq(t, "<")) --level;
    i -= 2;
  }
  ret i;
}

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: #1021797
Snippet name: tok_scanTypeBackwards (also jumps over package names)
Eternal ID of this version: #1021797/4
Text MD5: cc793182290087c06493e455ac16f477
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-09-09 22:33:47
Source code size: 436 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 368 / 376
Version history: 3 change(s)
Referenced in: [show references]