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

21
LINES

< > BotCompany Repo | #1003563 // expandEllipsis - replace "[...]" in occ tree with matching subtree

JavaX fragment (include)

// returns true if it worked ok
static bool expandEllipsis(OccTree2 tree) {
  bool ok = true;
  OccTree2 node = null;
  int safety = 0;
  while (++safety < 1000 && (node = findNode(tree, E.state("..."))) != null) {
    OccTree2 p = node.parent;
    L<OccTree2> l = findNodes(tree, p.e);
    l.remove(p);
    if (empty(l)) {
      print("Couldn't expand ellipsis after " + p.e);
      ok = false;
    }
    p.replaceWith(cloneOccTree(first(l)));
  }
  if (node != null) {
    print("Expand ellipsis: Warning - Safety count reached (" + safety + ")");
    ok = false;
  }
  ret ok;
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1003563
Snippet name: expandEllipsis - replace "[...]" in occ tree with matching subtree
Eternal ID of this version: #1003563/1
Text MD5: f6fcfab839a4bdf765bbbc1b2c5001fb
Author: stefan
Category: javax / talking robots
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-07-19 17:44:19
Source code size: 601 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 495 / 511
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)