Uses 911K of libraries. Click here for Pure Java version (2880L/15K).
!7 sclass Entry { S pattern; Map params; // null if not matched sS _fieldOrder = "pattern params"; } cmodule MatchingInputPatterns > DynObjectTable<Entry> { transient S input; transient LinkedHashSet<S> processedGroupings; start { set fieldsInOrder; dm_onTopInput_q(vf<S> process); process(dm_topInput()); dm_vmBus_onMessage_q('newInputGroupings, voidfunc(O mod, S _input, LS groupings) { print("Got groupings"); S topInput = dm_topInput(); if (neq(topInput, input)) process(topInput); if (neq(_input, input)) ret; for (S s : groupings) process2(s); }); } // happens in queue void process(S s) { clear(); input = s; processedGroupings = new LinkedHashSet; process2(s); } void process2(S s) { if (!processedGroupings.add(s)) ret; LS patterns = collect pattern((L) dm_requireAndCallModule("#1020518/InputPatterns", 'data)); print("Processing input " + quote(s) + " with " + n2(patterns, "pattern") + ": " + patterns); new Matches m; for (S pat : patterns) if (match3_plusBrackets(pat, s, m)) { add(nu(Entry, pattern := pat, params := matchesToMap(m))); print("Data length: " + l(data)); } } }
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: | 353 / 850 |
Version history: | 15 change(s) |
Referenced in: | [show references] |