Uses 911K of libraries. Click here for Pure Java version (2880L/15K).
1 | !7 |
2 | |
3 | sclass Entry {
|
4 | S pattern; |
5 | Map params; // null if not matched |
6 | |
7 | sS _fieldOrder = "pattern params"; |
8 | } |
9 | |
10 | cmodule MatchingInputPatterns > DynObjectTable<Entry> {
|
11 | transient S input; |
12 | transient LinkedHashSet<S> processedGroupings; |
13 | |
14 | start {
|
15 | set fieldsInOrder; |
16 | dm_onTopInput_q(vf<S> process); |
17 | process(dm_topInput()); |
18 | dm_vmBus_onMessage_q('newInputGroupings, voidfunc(O mod, S _input, LS groupings) {
|
19 | print("Got groupings");
|
20 | S topInput = dm_topInput(); |
21 | if (neq(topInput, input)) process(topInput); |
22 | if (neq(_input, input)) ret; |
23 | for (S s : groupings) process2(s); |
24 | }); |
25 | } |
26 | |
27 | // happens in queue |
28 | void process(S s) {
|
29 | clear(); |
30 | input = s; |
31 | processedGroupings = new LinkedHashSet; |
32 | process2(s); |
33 | } |
34 | |
35 | void process2(S s) {
|
36 | if (!processedGroupings.add(s)) ret; |
37 | |
38 | LS patterns = collect pattern((L) dm_requireAndCallModule("#1020518/InputPatterns", 'data));
|
39 | print("Processing input " + quote(s) + " with " + n2(patterns, "pattern") + ": " + patterns);
|
40 | new Matches m; |
41 | for (S pat : patterns) |
42 | if (match3_plusBrackets(pat, s, m)) {
|
43 | add(nu(Entry, pattern := pat, params := matchesToMap(m))); |
44 | print("Data length: " + l(data));
|
45 | } |
46 | } |
47 | } |
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1021051 |
| Snippet name: | Matching Input Patterns |
| Eternal ID of this version: | #1021051/16 |
| Text MD5: | 9d155dd8076d691ab4effdfcc89d5b9d |
| Transpilation MD5: | 1985ebb7b7654753c17ceec0ac1e17e8 |
| Author: | stefan |
| Category: | javax / stefan's os / a.i. |
| Type: | JavaX source code (Dynamic Module) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2019-01-19 19:10:41 |
| Source code size: | 1293 bytes / 47 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 617 / 1181 |
| Version history: | 15 change(s) |
| Referenced in: | [show references] |