Libraryless. Click here for Pure Java version (4012L/24K).
1 | sbool mmo2_match(MMOPattern pattern, S s) {
|
2 | ret mmo2_match(pattern, s, false, false); |
3 | } |
4 | |
5 | sbool mmo2_match(MMOPattern pattern, S s, bool startOfLine, bool endOfLine) {
|
6 | ifdef mmo2_match_debug |
7 | printFunctionCall mmo2_match_debug(pattern, s, startOfLine, endOfLine); |
8 | endifdef |
9 | if (pattern == null) false; |
10 | S s2 = trim(s); |
11 | if (pattern cast MMOPattern.StartOfLine) |
12 | ret mmo2_match(pattern.p, s2, true, endOfLine); |
13 | if (pattern cast MMOPattern.EndOfLine) |
14 | ret mmo2_match(pattern.p, s2, startOfLine, true); |
15 | if (pattern cast MMOPattern.Phrase) {
|
16 | S p = pattern.phrase; |
17 | if (pattern.quoted) ret cicWithSmartWordBoundary(s2, p); |
18 | if (startsWith(p, "#")) ret eqic(p, s2); |
19 | ret match3_startOrEndOfLine(p, s2, startOfLine, endOfLine); |
20 | } |
21 | if (pattern cast MMOPattern.And) |
22 | ret all(pattern.l, pat -> mmo2_match(pat, s2, startOfLine, endOfLine)); |
23 | if (pattern cast MMOPattern.Or) |
24 | ret any(pattern.l, pat -> mmo2_match(pat, s2, startOfLine, endOfLine)); |
25 | if (pattern cast MMOPattern.Not) |
26 | ret !mmo2_match(pattern.p, s2, startOfLine, endOfLine); |
27 | fail("what. " + pattern);
|
28 | } |
29 | |
30 | sbool mmo2_match(S pattern, S s) {
|
31 | ret mmo2_match(mmo2_parsePattern(pattern), s); |
32 | } |
Began life as a copy of #1026500
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1028074 |
| Snippet name: | mmo2_match - current "PhraseCache" matcher for chat bots |
| Eternal ID of this version: | #1028074/13 |
| Text MD5: | 8dc51ac813eaae5d63e7211e53f672c4 |
| Transpilation MD5: | 0d25628f71dddd10354aa17c16fc0592 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-11-02 12:43:06 |
| Source code size: | 1222 bytes / 32 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 526 / 1182 |
| Version history: | 12 change(s) |
| Referenced in: | [show references] |