Download Jar. Libraryless. Click here for Pure Java version (7285L/52K).
!7 p-exp { wordWrapConsole(); L<S> tok = javaTokPlusBrackets(mL_raw("Logic Example")); L<S> l = splitAtDoubleArrow(tok); if (l(l) != 2) ret; printStruct(new IfThen( parseExpression(first(l)), parseExpression(second(l)))); } static Exp parseExpression(S s) { L<S> tok = javaTokPlusBrackets(s); L<S> l = splitAtTokens(tok, ll("&", "", "&")); if (l(l) == 2) // TODO ret And(parseExpression(first(l)), parseExpression(second(l))); if (l(tok) == 5 && isIdentifier(tok.get(1)) && isRoundBracketed(tok.get(3))) ret Func(tok.get(1), parseExpression(deRoundBracket(tok.get(3)))); l = splitAtTokens(tok, ll("=")); if (l(l) == 2) ret Eq(parseExpression(first(l)), parseExpression(second(l))); ret Sentence(tok); } srecord IfThen(Exp in, Exp out) {} sclass Exp {} srecord Func(S name, Exp arg) extends Exp {} srecord And(Exp a, Exp b) extends Exp {} srecord Sentence(L<S> tok) extends Exp {} 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: | 666 / 1719 |
| Version history: | 7 change(s) |
| Referenced in: | [show references] |