// tok = CNC of the class static L<L<S>> allVariableDeclarations(L<S> tok) { new L<L<S>> l; int i = 1; while (!tok.get(i).equals("{")) i += 2; i += 2; // Now we're inside the class. while (i < tok.size() && !tok.get(i).equals("}")) { //print("i=" + i); // parse a declaration (constructor/method/variable/inner class) int j = i; L<S> special = litlist("=", "{", ";"); while (j < tok.size() && !special.contains(tok.get(j))) j += 2; if (tok.get(j).equals("{")) // method or class declaration - skip j = findEndOfBlock(tok, j)+1; else { // variable declaration if (tok.get(j).equals("=")) j = allVariableDeclarations_findEndOfInitializer(tok, j)+1; else j += 2; // skip ";" l.add(tok.subList(i-1, j)); } i = j; } return l; } // i is a code token pointing at the "=" // as usual, returns index of last code token + 1 static int allVariableDeclarations_findEndOfInitializer(L<S> tok, int i) { while (i < tok.size() && !tok.get(i).equals(";") && !tok.get(i).equals(",")) { if ("{<(".indexOf(tok.get(i)) >= 0) i = findEndOfBracketPart(tok, i)+1; else i += 2; } return i+1; }
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: | #1001159 |
Snippet name: | allVariableDeclarations |
Eternal ID of this version: | #1001159/1 |
Text MD5: | a14412b4e53ff1542b1d57449fc360ae |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-09-25 17:11:13 |
Source code size: | 1291 bytes / 45 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 642 / 879 |
Referenced in: | #1002427 - Accellerating 629 (SPIKE) #1006654 - Standard functions list 2 (LIVE, continuation of #761) #3000382 - Answer for ferdie (>> t = 1, f = 0) #3000383 - Answer for funkoverflow (>> t=1, f=0 okay) |