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

15
LINES

< > BotCompany Repo | #1010858 // matchDollarVars

JavaX fragment (include)

static SS matchDollarVars(S pat, S s) {
  new L<S> vars;
  S pat2 = dollarVarsToStars(pat, vars);
  new Matches m;
  if (!match(pat2, s, 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 (neq(oldValue, value)) null;
  }
  ret map;
}

Author comment

Began life as a copy of #1010855

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: #1010858
Snippet name: matchDollarVars
Eternal ID of this version: #1010858/2
Text MD5: 8a0fa57a4841e16bb2e5f5d49e2ed6e9
Author: stefan
Category: javax / parsing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-10-04 22:44:59
Source code size: 396 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 478 / 511
Version history: 1 change(s)
Referenced in: [show references]