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

14
LINES

< > BotCompany Repo | #1026499 // mmo_parsePattern

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

Libraryless. Click here for Pure Java version (2981L/18K).

1  
// s = e.g. "(what, give) + (mrnuke, mrnuke's, mr + (nuke, nuke's)) + (url, address)"
2  
static MMOPattern mmo_parsePattern(S s) {
3  
  s = trim(tok_deRoundBracket(trim(s)));
4  
  LS tok = javaTokWithBrackets(s);
5  
  LS l = tok_splitAtComma(tok);
6  
  if (l(l) > 1)
7  
    ret new MMOPattern.Or(lambdaMap mmo_parsePattern(l));
8  
  l = tok_splitAtPlus(s);
9  
  if (l(l) > 1)
10  
    ret new MMOPattern.And(lambdaMap mmo_parsePattern(l));
11  
  if (startsWith(s, "!"))
12  
    ret new MMOPattern.Not(mmo_parsePattern(dropFirst(s)));
13  
  ret new MMOPattern.Phrase(unquote(s), isQuoted(s));
14  
}

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: #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: 301 / 428
Version history: 5 change(s)
Referenced in: [show references]