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

16
LINES

< > BotCompany Repo | #1017132 // match2x

JavaX fragment (include)

1  
static S[] match2x(L<S> pat, L<S> tok) {
2  
  new ArrayList<S> result;
3  
  if (pat.size() != tok.size()) null;
4  
  for (int i = 1; i < pat.size(); i += 2) {
5  
    S p = pat.get(i), t = tok.get(i);
6  
    bool match;
7  
    if (eq(p, "*")) match = true;
8  
    else if (eq(p, "<quoted>")) match = isQuoted(t);
9  
    else if (eq(p, "<id>")) match = isIdentifier(t);
10  
    else if (eq(p, "<int>")) match = isInteger(t);
11  
    else { if (!eq(p, t)) null; continue; }
12  
    if (!match) null;
13  
    result.add(t);
14  
  }
15  
  return result.toArray(new S[result.size()]);
16  
}

Author comment

Began life as a copy of #1000812

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1017132
Snippet name: match2x
Eternal ID of this version: #1017132/2
Text MD5: 738f9f91f238993d54e2145ff9568bcc
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-07-12 17:58:31
Source code size: 549 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 341 / 388
Version history: 1 change(s)
Referenced in: [show references]