Download Jar. Libraryless. Click here for Pure Java version (7941L/56K).
1 | !7 |
2 | |
3 | static withToList record Did$HappenBefore$(O event1, O event2) {} |
4 | static withToList record WhenDid$Happen(O event) {} |
5 | static withToList record $HappensAtSecond$(O event, O y) {} |
6 | |
7 | static cached L<Class> recordClasses() { ret (L) myNonAbstractClassesImplementing(IFieldsToList); } |
8 | |
9 | static cached LPair<Class, S> classesAndPatterns() { |
10 | ret map(recordClasses(), |
11 | c -> pair(c, dollarsToStarsAndSplitCamelCase(classNameRelativeToMC(c)))); |
12 | } |
13 | |
14 | sO parseArg(S s) { ret isInteger(s) ? parseInt(s) : s; } |
15 | |
16 | sO parse(S s) { |
17 | new Matches m; |
18 | for (Pair<Class, S> p : classesAndPatterns()) { |
19 | if (match3_plusBrackets_uncurly(p.b, s, m)) |
20 | ret nuObject(p.a, mapToObjectArray parseArg(m.m)); |
21 | } |
22 | null; |
23 | } |
24 | |
25 | p-exp { |
26 | pnl(pairsB(classesAndPatterns())); |
27 | testFunctionValues parse( |
28 | "Did X happen before Y?" := Did$HappenBefore$("X", "Y"), |
29 | "when did Z happen" := WhenDid$Happen("Z"), |
30 | "{event 1} happens at second 100" := $HappensAtSecond$("event 1", 100) |
31 | ); |
32 | } |
Began life as a copy of #1025431
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, omdjrrnzbjjv, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1025442 |
Snippet name: | Propositions to objects, step 6 - parsing (OK) |
Eternal ID of this version: | #1025442/28 |
Text MD5: | 10263169b2cc208b1304492e0ecffd6b |
Transpilation MD5: | 325f63048670d0fa40856e9ca653d940 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-09-29 01:14:02 |
Source code size: | 1000 bytes / 32 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 290 / 984 |
Version history: | 27 change(s) |
Referenced in: | [show references] |