Libraryless. Click here for Pure Java version (3412L/21K).
1 | sS tok_expandIfQuoted(S s) { ret applyTranspilationFunction tok_expandIfQuoted(s); }
|
2 | |
3 | svoid tok_expandIfQuoted(LS tok) {
|
4 | jreplace(tok, "if <quoted> || <quoted>", |
5 | "if (matchOneOf(s, m, $2, $5))"); |
6 | |
7 | // "bla * bla | blubb * blubb" |
8 | jreplace_dyn(tok, "if <quoted>", func(L<S> tok, int cIdx) -> S {
|
9 | S s = unquote(tok.get(cIdx+2)); |
10 | //print("multimatch: " + quote(s));
|
11 | new L<S> l; |
12 | for (S pat : splitAtJavaToken(s, "|")) {
|
13 | //print("multimatch part: " + quote(pat));
|
14 | if (pat.contains("..."))
|
15 | l.add("matchX(" + quote(trim(pat)) + ", s, m)");
|
16 | else if (javaTok(pat).contains("*"))
|
17 | l.add("match(" + quote(trim(pat)) + ", s, m)");
|
18 | else |
19 | l.add("match(" + quote(trim(pat)) + ", s)");
|
20 | } |
21 | ret "if (" + join(" || ", l) + ")";
|
22 | }, tokcondition {
|
23 | ret javaTokC(unquote(tok.get(i+3))).contains("|");
|
24 | }); |
25 | |
26 | tok_transpileIfQuoted_dollarVars(tok); |
27 | |
28 | // "...bla..." |
29 | jreplace(tok, "if <quoted>", "if (find3plusRestsX($2, s, m))", |
30 | tokcondition {
|
31 | ret startsAndEndsWith(unquote(tok.get(i+3)), "..."); |
32 | }); |
33 | |
34 | // "bla..." |
35 | jreplace(tok, "if <quoted>", "if (matchStartX($2, s, m))", |
36 | tokcondition {
|
37 | ret unquote(tok.get(i+3)).endsWith("...");
|
38 | }); |
39 | |
40 | // "bla" |
41 | jreplace(tok, "if <quoted>", "if (match($2, s))", |
42 | tokcondition {
|
43 | ret !javaTokC(unquote(tok.get(i+3))).contains("*");
|
44 | }); |
45 | |
46 | // "bla * bla" |
47 | jreplace(tok, "if <quoted>", "if (match($2, s, m))"); |
48 | jreplace(tok, "if match <quoted>", "if (match($3, s, m))"); |
49 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1027559 |
| Snippet name: | tok_expandIfQuoted |
| Eternal ID of this version: | #1027559/4 |
| Text MD5: | dd35c127d376521d583f314f72370401 |
| Transpilation MD5: | a9b46301928d3515cf43304793707db9 |
| Author: | stefan |
| Category: | javax / transpiling |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-03-29 20:11:45 |
| Source code size: | 1584 bytes / 49 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 484 / 650 |
| Version history: | 3 change(s) |
| Referenced in: | [show references] |