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

27
LINES

< > BotCompany Repo | #1001876 // jmatch function (match with javaTok, keeps punctuation) - pattern goes first (unlike jfind). See also jmatch2

JavaX fragment (include)

// DIFFERENCES to jfind: always ignores case, doesn't recognize <id> etc
// You probably want jmatch2

static boolean jmatch(S pat, S s) {
  return jmatch(pat, s, null);
}

static boolean jmatch(S pat, S s, Matches matches) {
  if (s == null) return false;
  ret jmatch(pat, javaTok(s), matches);
}

static boolean jmatch(S pat, L<S> toks) {
  ret jmatch(pat, toks, null);
}

static boolean jmatch(S pat, L<S> toks, Matches matches) {
  L<S> tokpat = javaTok(pat);
  S[] m = match2(tokpat, toks);
  //print(structure(tokpat) + " on " + structure(toks) + " => " + structure(m));
  if (m == null)
    ret false;
  else {
    if (matches != null) matches.m = m;
    ret true;
  }
}

Author comment

Began life as a copy of #1001104

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1001876
Snippet name: jmatch function (match with javaTok, keeps punctuation) - pattern goes first (unlike jfind). See also jmatch2
Eternal ID of this version: #1001876/7
Text MD5: d3df658ced648c9bd405fe91713ad24c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-09-11 22:54:59
Source code size: 704 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 749 / 999
Version history: 6 change(s)
Referenced in: [show references]