1 | static S snlToText(S s) { |
2 | ret snlToText(snlToTree(s)); |
3 | } |
4 | |
5 | static S snlToText(Lisp tree) { |
6 | if (tree == null) ret ""; |
7 | tree = snlRemoveReferences(tree); |
8 | |
9 | if (snlToText_isJuxta(tree)) |
10 | tree = snlToText_addDots(tree); |
11 | |
12 | tree = snlQuestionMarksToBack(tree); |
13 | |
14 | S snl = snlFromTree(tree); |
15 | new StringBuilder buf; |
16 | L<S> drop = litlist ("[", "]", "<", ">"); |
17 | for (S t : codeTokensOnly(snlTok(snl))) |
18 | if (!drop.contains(t)) { |
19 | if (buf.length() != 0 && !litlist(".", "?").contains(t)) |
20 | buf.append(" "); |
21 | buf.append(t); |
22 | } |
23 | ret str(buf); |
24 | } |
25 | |
26 | static boolean snlToText_isJuxta(Lisp tree) { |
27 | ret eq("*", join(asList(new HashSet<S>(codeTokensOnly(javaTok(tree.head)))))); |
28 | } |
29 | |
30 | static Lisp snlToText_addDots(Lisp tree) { |
31 | Lisp t = new Lisp(tree.head); |
32 | for (Lisp x : tree) { |
33 | if (x.isA("<") && !x.get(0).is("?", ".")) |
34 | x = lisp("<", ".", x); |
35 | t.add(x); |
36 | } |
37 | ret t; |
38 | } |
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: | #1002729 |
Snippet name: | snlToText |
Eternal ID of this version: | #1002729/1 |
Text MD5: | 63e0347b87b5943a6e505d441e584afc |
Author: | stefan |
Category: | eleu / nl |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-02-24 21:33:18 |
Source code size: | 943 bytes / 38 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 672 / 671 |
Referenced in: | [show references] |