// split smth like "if * then *" into "if *" and "then *" // returns null if no split // now also for NL trees static L<Lisp> snlSplitOps(Lisp code) { new L<Lisp> out; if (code.is("[]")) { // NL if ((code.size() & 1) != 0) ret null; for (int i = 0; i < code.size(); i += 2) { Lisp op = code.get(i), arg = code.get(i+1); if (!op.isLeaf() || !isExtendedIdentifier(op.head)) ret null; out.add(lisp(op + " *", nlUnbracket(arg))); } ret out; } S ops = code.head; L<S> tok = codeTokensOnly(javaTok(ops)); if ((l(tok) & 1) != 0) ret null; for (int i = 0; i < l(tok); i += 2) { S op = tok.get(i); if (!isIdentifier(op) || neq("*", tok.get(i+1))) ret null; out.add(lisp(op + " *", code.get(i/2))); } //print("splitOps => " + structure(out)); ret out; }
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: | #1002756 |
Snippet name: | snlSplitOps |
Eternal ID of this version: | #1002756/1 |
Text MD5: | 1f0f73536ec0ab3b08c4d49b52b02087 |
Author: | stefan |
Category: | eleu / nl |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-03-03 02:17:41 |
Source code size: | 858 bytes / 30 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 680 / 860 |
Referenced in: | [show references] |