// tok = CNC of the class static L> allVariableDeclarations(L tok) { new L> 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 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 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; }