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

21
LINES

< > BotCompany Repo | #1010862 // matchDollarVarsIC - use match() with dollar vars

JavaX fragment (include)

static SS matchDollarVarsIC(S pat, S s) {
  if (s == null) null;
  ret matchDollarVarsIC(pat, parse3_cachedInput(s));
}

static SS matchDollarVarsIC(S pat, LS tokS) {
  if (pat == null || tokS == null) null;
  new L<S> vars;
  S pat2 = dollarVarsToStars(pat, vars);
  new Matches m;
  if (!match3(pat2, tokS, m)) null;
  new SS map;
  for (int i = 0; i < l(m.m); i++) {
    S var = vars.get(i);
    S value = m.get(i);
    S oldValue = map.get(var);
    if (oldValue == null) map.put(var, value);
    else if (neqic(oldValue, value)) null;
  }
  ret map;
}

Author comment

Began life as a copy of #1010858

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1010862
Snippet name: matchDollarVarsIC - use match() with dollar vars
Eternal ID of this version: #1010862/6
Text MD5: 9dcf9d3d84346de32b7f3fa39472ac0a
Author: stefan
Category: javax / parsing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-09-02 23:26:39
Source code size: 576 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 585 / 632
Version history: 5 change(s)
Referenced in: [show references]