Download Jar. Libraryless. Click here for Pure Java version (7285L/52K).
1 | !7 |
2 | |
3 | p-exp { |
4 | wordWrapConsole(); |
5 | L<S> tok = javaTokPlusBrackets(mL_raw("Logic Example")); |
6 | L<S> l = splitAtDoubleArrow(tok); |
7 | if (l(l) != 2) ret; |
8 | printStruct(new IfThen( |
9 | parseExpression(first(l)), |
10 | parseExpression(second(l)))); |
11 | } |
12 | |
13 | static Exp parseExpression(S s) { |
14 | L<S> tok = javaTokPlusBrackets(s); |
15 | L<S> l = splitAtTokens(tok, ll("&", "", "&")); |
16 | if (l(l) == 2) // TODO |
17 | ret And(parseExpression(first(l)), parseExpression(second(l))); |
18 | if (l(tok) == 5 && isIdentifier(tok.get(1)) && isRoundBracketed(tok.get(3))) |
19 | ret Func(tok.get(1), parseExpression(deRoundBracket(tok.get(3)))); |
20 | l = splitAtTokens(tok, ll("=")); |
21 | if (l(l) == 2) |
22 | ret Eq(parseExpression(first(l)), parseExpression(second(l))); |
23 | ret Sentence(tok); |
24 | } |
25 | |
26 | srecord IfThen(Exp in, Exp out) {} |
27 | sclass Exp {} |
28 | srecord Func(S name, Exp arg) extends Exp {} |
29 | srecord And(Exp a, Exp b) extends Exp {} |
30 | srecord Sentence(L<S> tok) extends Exp {} |
31 | srecord Eq(Exp left, Exp right) extends Exp {} |
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: | #1017545 |
Snippet name: | Parse Logic Rule Spike [OK] |
Eternal ID of this version: | #1017545/8 |
Text MD5: | e9809bea0a20d63eb826c5743376c101 |
Transpilation MD5: | bce9aa0917f2d4e2f7ba1ff4add234de |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-07-28 11:20:10 |
Source code size: | 1003 bytes / 31 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 415 / 1120 |
Version history: | 7 change(s) |
Referenced in: | [show references] |