1 | // i is index of last token of expression |
2 | // return value is C token |
3 | static int tok_findBeginningOfJavaXTerm(L<S> tok, int i) { |
4 | i |= 1; |
5 | int level = 0; |
6 | |
7 | while (i > 1) { |
8 | S t = get(tok, i); |
9 | if (eqOneOf(t, "}", ")")) level++; |
10 | else if (eqOneOf(t, "{", "(")) level--; |
11 | if (level == 0) { |
12 | S prev = get(tok, i-2); |
13 | printVars_str(+prev, +t); |
14 | if (eqOneOf(prev, "ret", "return") |
15 | || isIdentifier(t) |
16 | && !isIdentifier(prev) |
17 | && !eq(prev, ".")) { |
18 | ifdef tok_findBeginningOfJavaXTerm_debug |
19 | print("Returning " + i + " / " + t); |
20 | endifdef |
21 | ret i; |
22 | } |
23 | } |
24 | i -= 2; |
25 | } |
26 | |
27 | ret i; |
28 | } |
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1026294 |
Snippet name: | tok_findBeginningOfJavaXTerm [dev.] |
Eternal ID of this version: | #1026294/12 |
Text MD5: | becc9a0adb2e70828873d915581b5e1e |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-06-28 23:45:07 |
Source code size: | 699 bytes / 28 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 247 / 300 |
Version history: | 11 change(s) |
Referenced in: | [show references] |