Libraryless. Click here for Pure Java version (2477L/16K).
static Set<S> findFullFunctionDefs_keywords = new HashSet(splitAtSpace("static svoid ssvoid ssynchronized sbool sS sO sL")); // returns actual CNC static LL<S> findFullFunctionDefs(L<S> tok, bool topLevelOnly) { int n = l(tok); new LL<S> 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<S> findFullFunctionDefs(S s, bool topLevelOnly) { ret findFullFunctionDefs(javaTok(s), topLevelOnly); }
Began life as a copy of #1004051
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1008142 |
Snippet name: | findFullFunctionDefs - static functions only |
Eternal ID of this version: | #1008142/8 |
Text MD5: | 8a6220c23cbbf05c49e1abc579d15882 |
Transpilation MD5: | 51f221af5bee1b19f1259f784da79e4e |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-02-17 16:47:00 |
Source code size: | 1151 bytes / 34 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 508 / 621 |
Version history: | 7 change(s) |
Referenced in: | [show references] |