1 | static SS matchDollarVarsIC_underscores(S pat, S s) { |
2 | pcall { |
3 | if (pat == null || s == null) null; |
4 | new L<S> vars; |
5 | S pat2 = dropSuffix("...", dollarVarsToStars_underscoresWithDollarQ(pat, vars)); |
6 | s = dropSuffix("...", s); |
7 | new Matches m; |
8 | if (!match(pat2, s, m)) null; |
9 | new SS map; |
10 | int v = 0; |
11 | for (int i = 0; i < l(m.m); ) { |
12 | S var = vars.get(v++); |
13 | bool quoted = startsWith(var, "$_q_"); |
14 | if (quoted) { |
15 | S value = m.m[i++]; |
16 | if (!isQuoted(value)) null; |
17 | var = "$" + substring(var, 4); |
18 | if (!strictPutIC(map, var, unquote(value))) null; |
19 | } else { |
20 | int n = underscoreWordCount(var); |
21 | S value = joinWithSpace(subStringArray(m.m, i, i+n)); |
22 | if (!strictPutIC(map, var, value)) null; |
23 | i += n; |
24 | } |
25 | } |
26 | ret map; |
27 | } null; |
28 | } |
Began life as a copy of #1010862
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1017695 |
Snippet name: | matchDollarVarsIC_underscores - use match() with dollar vars, underscore indicates word break. now also supports $_q_name for quoted values |
Eternal ID of this version: | #1017695/13 |
Text MD5: | 66bbc8e013f1ca18df19988003223d8f |
Author: | stefan |
Category: | javax / parsing |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-08-20 19:18:40 |
Source code size: | 812 bytes / 28 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 451 / 506 |
Version history: | 12 change(s) |
Referenced in: | [show references] |