Libraryless. Click here for Pure Java version (2477L/16K).
1 | static Set<S> findFullFunctionDefs_keywords = new HashSet(splitAtSpace("static svoid ssvoid ssynchronized sbool sS sO sL")); |
2 | |
3 | // returns actual CNC |
4 | static LL<S> findFullFunctionDefs(L<S> tok, bool topLevelOnly) { |
5 | int n = l(tok); |
6 | new LL<S> functions; |
7 | for (int i = 1; i < n; i += 2) { |
8 | S t = tok.get(i); |
9 | if (topLevelOnly && eq(t, "{")) i = findEndOfBlock(tok, i)-1; |
10 | else if (findFullFunctionDefs_keywords.contains(t)) { |
11 | ifdef findFullFunctionDefs_debug |
12 | print("Keyword! " + t); |
13 | endifdef |
14 | int j = i+2; |
15 | while (j < n && !eqOneOf(tok.get(j), ";", "=", "(", "{")) |
16 | j += 2; |
17 | if ((eqGet(tok, j, "(") || eq(t, "svoid") && eqGet(tok, j, "{")) |
18 | && isIdentifier(tok.get(j-2)) |
19 | && !contains(subList(tok, i, j), "new")) { |
20 | int k = smartIndexOf(tok, "{", j); |
21 | if (k < l(tok)) { |
22 | k = findEndOfBlock(tok, k)+1; |
23 | functions.add(subList(tok, i-1, k)); |
24 | i = k-2; |
25 | } |
26 | } |
27 | } |
28 | } |
29 | ret functions; |
30 | } |
31 | |
32 | static LL<S> findFullFunctionDefs(S s, bool topLevelOnly) { |
33 | ret findFullFunctionDefs(javaTok(s), topLevelOnly); |
34 | } |
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: | 509 / 623 |
Version history: | 7 change(s) |
Referenced in: | [show references] |