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)

1  
static SS matchDollarVarsIC(S pat, S s) {
2  
  if (s == null) null;
3  
  ret matchDollarVarsIC(pat, parse3_cachedInput(s));
4  
}
5  
6  
static SS matchDollarVarsIC(S pat, LS tokS) {
7  
  if (pat == null || tokS == null) null;
8  
  new L<S> vars;
9  
  S pat2 = dollarVarsToStars(pat, vars);
10  
  new Matches m;
11  
  if (!match3(pat2, tokS, m)) null;
12  
  new SS map;
13  
  for (int i = 0; i < l(m.m); i++) {
14  
    S var = vars.get(i);
15  
    S value = m.get(i);
16  
    S oldValue = map.get(var);
17  
    if (oldValue == null) map.put(var, value);
18  
    else if (neqic(oldValue, value)) null;
19  
  }
20  
  ret map;
21  
}

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: 586 / 634
Version history: 5 change(s)
Referenced in: [show references]