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

16
LINES

< > BotCompany Repo | #1030935 // match3_withIntsAndIDs - understands "*", "<int>" and "<id>"

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

Transpiled version (3473L) is out of date.

sbool match3_withIntsAndIDs(S pat, S s, Matches m default null) {
  LS tokPat = javaTokWithAllPlusAngleBrackets(pat);
  S pat2 = joinMap(tokPat, t -> eqOneOf(t, "<int>", "<id>") ? "*" : t);
  Matches m2 = m == null ? new Matches : m;
  ifdef match3_withIntsAndIDs_debug
    printVars_str match3_withInts(+pat2, +s);
  endifdef
  if (!match3(pat2, s, m2)) false;
  LS vars = filter(codeTokens(tokPat), t -> eqOneOf(t, "<int>", "<id>", "*"));
  for i over vars: {
    if (eq(vars.get(i), "<int>") && !isInteger(m2.get(i))
      || eq(vars.get(i), "<id>") && !isIdentifier(m2.get(i)))
      false;
  }
  true;
}

Author comment

Began life as a copy of #1030933

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030935
Snippet name: match3_withIntsAndIDs - understands "*", "<int>" and "<id>"
Eternal ID of this version: #1030935/4
Text MD5: 67e667294db2ff0504d7b8f00d7e392c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-04-12 17:40:51
Source code size: 623 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 85 / 143
Version history: 3 change(s)
Referenced in: [show references]