static Exp nlLogic_parseExpression(S s) { if (s == null) null; L<S> tok = javaTokPlusAllThreeBrackets(s); // a && b PairS p = splitAtTokens_once(tok, ll("&", "", "&")); if (p != null) ret And(nlLogic_parseExpression(first(p)), nlLogic_parseExpression(second(p))); // !a if (eqGet(tok, 1, "!")) ret ExpNot(nlLogic_parseExpression(join(dropFirst(2, tok)))); // function with options - a[bla, blubb](...) if (l(tok) == 7 && isIdentifier(tok.get(1)) && isSquareBracketed(tok.get(3)) && isRoundBracketed(tok.get(5))) ret Func(tok.get(1), tok_splitAtComma(deSquareBracket(tok.get(3))), nlLogic_parseExpression(deRoundBracket(tok.get(5)))); // function - a(...) if (l(tok) == 5 && isIdentifier(tok.get(1)) && isRoundBracketed(tok.get(3))) { S name = tok.get(1), arg = deRoundBracket(tok.get(3)); bool parseInnerPart = false; ret Func(name, parseInnerPart ? nlLogic_parseExpression(arg) : Sentence2(unquoteIfNormalQuoted(arg))); } // a = b LS l = splitAtTokens(tok, ll("=")); if (l(l) == 2) ret Eq(nlLogic_parseExpression(first(l)), nlLogic_parseExpression(second(l))); // default ret Sentence2(l(tok) == 3 && isQuoted(tok.get(1)) ? unquote(second(tok)) : join(tok)); }
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: | #1017548 |
| Snippet name: | nlLogic_parseExpression |
| Eternal ID of this version: | #1017548/12 |
| Text MD5: | 08996e91773b7d0e0f7979f664379161 |
| Author: | stefan |
| Category: | javax / a.i. |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-08-25 10:41:22 |
| Source code size: | 1313 bytes / 37 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 591 / 658 |
| Version history: | 11 change(s) |
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |