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

23
LINES

< > BotCompany Repo | #1017429 // ai_matchParseTrees_v2

JavaX fragment (include)

static L<Pair<O>> ai_matchParseTrees_v2(PTElement a, PTElement b) {
  new L<Pair<O>> out;
  ai_matchParseTrees_v2_collect(a, b, out);
  ret out;
}

svoid ai_matchParseTrees_v2_collect(PTElement a, PTElement b, L<Pair<O>> out) {
  PTElement a2 = ai_parseTree_descendToComposite(a);
  PTElement b2 = ai_parseTree_descendToComposite(b);
  
  PTElement aa = or(a2, a), bb = or(b2, b);
  
  if (a2 != null && b2 != null) {
    // The actual match is between the productions.
    // We add the tree nodes too for reference.
    addPair(out,
      pairWithToStringFromA(a2/ChoosePart.reconstruction.production, a2),
      pairWithToStringFromA(b2/ChoosePart.reconstruction.production, b2));
    ai_matchParseTrees_v2_collect(first(a2.children), first(b2.children), out);
    ai_matchParseTrees_v2_collect(second(a2.children), second(b2.children), out);
  } else
    addPair(out, aa, bb);
}

Author comment

Began life as a copy of #1017424

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: #1017429
Snippet name: ai_matchParseTrees_v2
Eternal ID of this version: #1017429/6
Text MD5: 260d22a881b7c75467df85b80f999ebf
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-07-20 15:34:20
Source code size: 904 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 329 / 380
Version history: 5 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)