static Set findFullFunctionDefs_keywords = new HashSet(splitAtSpace("static svoid ssvoid ssynchronized sbool sS sO sL")); // returns actual CNC static LL findFullFunctionDefs(L tok, bool topLevelOnly) { int n = l(tok); new LL functions; for (int i = 1; i < n; i += 2) { S t = tok.get(i); if (topLevelOnly && eq(t, "{")) i = findEndOfBlock(tok, i)-1; else if (findFullFunctionDefs_keywords.contains(t)) { ifdef findFullFunctionDefs_debug print("Keyword! " + t); endifdef int j = i+2; while (j < n && !eqOneOf(tok.get(j), ";", "=", "(", "{")) j += 2; if ((eqGet(tok, j, "(") || eq(t, "svoid") && eqGet(tok, j, "{")) && isIdentifier(tok.get(j-2)) && !contains(subList(tok, i, j), "new")) { int k = smartIndexOf(tok, "{", j); if (k < l(tok)) { k = findEndOfBlock(tok, k)+1; functions.add(subList(tok, i-1, k)); i = k-2; } } } } ret functions; } static LL findFullFunctionDefs(S s, bool topLevelOnly) { ret findFullFunctionDefs(javaTok(s), topLevelOnly); }