Libraryless. Click here for Pure Java version (2189L/14K).
1 | static bool matchStart(S pat, S s) {
|
2 | ret matchStart(pat, s, null); |
3 | } |
4 | |
5 | // matches are as you expect, plus an extra item for the rest string |
6 | static bool matchStart(S pat, S s, Matches matches) {
|
7 | if (s == null) false; |
8 | ret matchStart(pat, parse3_cachedInput(s), matches); |
9 | } |
10 | |
11 | static bool matchStart(S pat, LS toks, Matches matches) {
|
12 | if (toks == null) false; |
13 | L<S> tokpat = parse3_cachedPattern(pat); |
14 | if (toks.size() < tokpat.size()) ret false; |
15 | S[] m = match2(tokpat, toks.subList(0, tokpat.size())); |
16 | //print(structure(tokpat) + " on " + structure(toks) + " => " + structure(m)); |
17 | if (m == null) false; |
18 | if (matches != null) {
|
19 | matches.m = new S[m.length+1]; |
20 | arraycopy(m, matches.m); |
21 | matches.m[m.length] = joinSubList(toks, tokpat.size(), toks.size()); // for Matches.rest() |
22 | } |
23 | true; |
24 | } |
Began life as a copy of #1001104
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1001793 |
| Snippet name: | matchStart function - match first tokens, return rest |
| Eternal ID of this version: | #1001793/4 |
| Text MD5: | b425b30c55222f560445f16f17c57adc |
| Transpilation MD5: | 36d1849096cfe1dbb09f1ef2982bd09d |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2019-05-18 23:40:51 |
| Source code size: | 836 bytes / 24 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 1060 / 2279 |
| Version history: | 3 change(s) |
| Referenced in: | [show references] |