Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

20
LINES

< > BotCompany Repo | #1026500 // mmo_match_parsedPattern

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3663L/23K).

1  
sbool mmo_match_parsedPattern(MMOPattern pattern, S s) {
2  
  S s2 = trim(s);
3  
  if (pattern == null) false;
4  
  if (pattern cast MMOPattern.Phrase) {
5  
    S p = pattern.phrase;
6  
    if (pattern.quoted) ret cicWithSmartWordBoundary(s2, p);
7  
    ret startsWith(p, "#") ? eqic(p, s2) : find3(p, s2);
8  
  }
9  
  if (pattern cast MMOPattern.And)
10  
    ret all(pattern.l, pat -> mmo_match_parsedPattern(pat, s2));
11  
  if (pattern cast MMOPattern.Or)
12  
    ret any(pattern.l, pat -> mmo_match_parsedPattern(pat, s2));
13  
  if (pattern cast MMOPattern.Not)
14  
    ret !mmo_match_parsedPattern(pattern.p, s2);
15  
  fail("what. " + pattern);
16  
}
17  
18  
sbool mmo_match_parsedPattern(S pattern, S s) {
19  
  ret mmo_match_parsedPattern(mmo_parsePattern_cached(pattern), s);
20  
}

Author comment

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: #1026500
Snippet name: mmo_match_parsedPattern
Eternal ID of this version: #1026500/10
Text MD5: cb47eea20aff35f947aa68630f5d6a93
Transpilation MD5: 5ad8f3e93706b7f915a1015f53ddb1dc
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-05-15 15:18:31
Source code size: 743 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 333 / 526
Version history: 9 change(s)
Referenced in: [show references]