/* Binding levels: 0 = lowest 1 = arrows (> lowest) 2 = word (> arrows) 3 = juxta, idword, subword (> word) */ static S snlFromTree(Lisp t) { ret snlFromTree(t, 0, null); } static S snlFromTree(Lisp t, int level, S arrow) { if (t == null) ret ""; if (t.isEmpty()) ret t.head; if (t.isA("<")) ret snlFromTree_wrap(level, eq(arrow, "<") ? 1 : 0, snlFromTree(t.get(0), 2, null) + " < "+ snlFromTree(t.get(1), 1, "<")); if (t.isA(">")) ret snlFromTree_wrap(level, eq(arrow, ">") ? 1 : 0, snlFromTree(t.get(0), 2, null) + " > "+ snlFromTree(t.get(1), 1, ">")); // it's a juxtaposition new L<S> l; int i = 0; for (S tok : codeTokensOnly(javaTok(t.head))) { if (eq(tok, "*") && i < t.size()) tok = snlFromTree(t.get(i++), 2, null); l.add(tok); } ret snlFromTree_wrap(level, 1, join(" ", l)); } static S snlFromTree_wrap(int outer, int inner, S s) { if (inner < outer) ret "[" + s + "]"; ret s; }
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: | #1002715 |
Snippet name: | snlFromTree |
Eternal ID of this version: | #1002715/1 |
Text MD5: | 6c2cda1c4bba8140476b79db5344f0d8 |
Author: | stefan |
Category: | nl bots |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-02-24 21:32:52 |
Source code size: | 985 bytes / 37 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 722 / 813 |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #3000382 - Answer for ferdie (>> t = 1, f = 0) #3000383 - Answer for funkoverflow (>> t=1, f=0 okay) |