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).

// 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));
}

Author comment

Began life as a copy of #1026018

download  show line numbers  debug dex   

Travelled to 4 computer(s): mqqgnosmbjvj, tvejysmllsmz, 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: 39 / 87
Version history: 5 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1026499 & http://1026499.tinybrain.de