Libraryless. Click here for Pure Java version (2981L/18K).
// s = e.g. "(what, give) + (mrnuke, mrnuke's, mr + (nuke, nuke's)) + (url, address)" static MMOPattern mmo_parsePattern(S s) { s = trim(tok_deRoundBracket(trim(s))); LS tok = javaTokWithBrackets(s); LS l = tok_splitAtComma(tok); if (l(l) > 1) ret new MMOPattern.Or(lambdaMap mmo_parsePattern(l)); l = tok_splitAtPlus(s); if (l(l) > 1) ret new MMOPattern.And(lambdaMap mmo_parsePattern(l)); if (startsWith(s, "!")) ret new MMOPattern.Not(mmo_parsePattern(dropFirst(s))); ret new MMOPattern.Phrase(unquote(s), isQuoted(s)); }
Began life as a copy of #1026018
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1026499 |
| Snippet name: | mmo_parsePattern |
| Eternal ID of this version: | #1026499/6 |
| Text MD5: | 8ea478f77e00397023f0b0c9d30fa520 |
| Transpilation MD5: | 1d1050bafd692cb2e0032078383d2c78 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-01-12 15:27:54 |
| Source code size: | 565 bytes / 14 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 560 / 738 |
| Version history: | 5 change(s) |
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1026501 - MMOPattern #1028065 - mmo_parsePattern_cached #1028071 - mmo2_parsePattern - V2 of the NLP pattern language - with ^, $ and weights |