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

32
LINES

< > BotCompany Repo | #1002594 // jmatchStart function - don't use. use jMatchStart instead, it supports <quoted> etc

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

Transpiled version (10949L) is out of date.

sbool jmatchStart(S pat, S s) {
  ret jmatchStart(pat, s, null);
}

// matches are as you expect, plus an extra item for the rest string
sbool jmatchStart(S pat, S s, Matches matches) {
  if (s == null) false;
  LS tokpat = javaTok(pat), toks = javaTok(s);
  ret jmatchStart(tokpat, toks, matches);
}
  
sbool jmatchStart(S pat, LS toks, Matches matches default null) {
  if (toks == null) false;
  LS tokpat = javaTok(pat);
  ret jmatchStart(tokpat, toks, matches);
}

sbool jmatchStart(LS tokpat, LS toks, Matches matches) {
  if (tokpat == null || toks == null || toks.size() < tokpat.size()) ret false;
  S[] m = match2(tokpat, toks.subList(0, tokpat.size()));
  //print(structure(tokpat) + " on " + structure(toks) + " => " + structure(m));
  if (m == null)
    return false;
  else {
    if (matches != null) {
      matches.m = new S[m.length+1];
      arraycopy(m, matches.m);
      matches.m[m.length] = join(toks.subList(tokpat.size(), toks.size())); // for Matches.rest()
    }
    return true;
  }
}

Author comment

Began life as a copy of #1001793

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: #1002594
Snippet name: jmatchStart function - don't use. use jMatchStart instead, it supports <quoted> etc
Eternal ID of this version: #1002594/7
Text MD5: 956c292d9be6b3b3c2e261a721ec93d7
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-10-25 17:40:19
Source code size: 1042 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 633 / 664
Version history: 6 change(s)
Referenced in: [show references]