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

14
LINES

< > BotCompany Repo | #1002125 // findInitializers - finds initializers in C-ish code

JavaX fragment (include)

1  
static MultiMap<S, S> findInitializers(S s) {
2  
  L<S> tok = javaTok(s);
3  
  Map<Integer, Integer> bracketMap = getBracketMap(tok);
4  
  new MultiMap<S, S> map;
5  
  int i = 0;
6  
  while ((i = findCodeTokens(tok, i+1, "<id>", "=")) >= 0) {
7  
    S name = tok.get(i);
8  
    if (eq(get(tok, i+4), "=")) continue; // it's ==, not =
9  
    if (litlist(">", ".").contains(get(tok, i-2))) continue; // it's -> or .
10  
    int j = scanToEndOfInitializer(tok, bracketMap, i+4);
11  
    map.put(name, join(tok.subList(i+4, j)));
12  
  }
13  
  ret map;
14  
}

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: #1002125
Snippet name: findInitializers - finds initializers in C-ish code
Eternal ID of this version: #1002125/1
Text MD5: c1a18a81c5c87c5b048d7069d1b2a752
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-12-20 22:37:59
Source code size: 523 bytes / 14 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 681 / 920
Referenced in: [show references]