!7 srecord IfThen(Exp in, Exp out) {} sclass Exp {} srecord And(Exp a, Exp b) extends Exp {} srecord Sentence(S text) extends Exp {} p-exp { jtattoo(); S input = first(mL("Monolog examples")); TextNode root = new(input); processNode_recursive(root, 10); showFrame(jDynamicTree(root, func(CTNode n) -> Collection<CTNode> { n.children })); } svoid processNode_recursive(CTNode n, int depthCounter) { if (n == null || depthCounter <= 0) ret; processNode(n); for (CTNode child : n.children) processNode_recursive(child, depthCounter-1); makeResults(n); } svoid makeResults(CTNode n) { if (!n instanceof OpNode) ret; for (TokNode child : instancesOf(TokNode, n.children)) } svoid processNode(CTNode n) { if (n instanceof TextNode) { TextNode tn = cast n; OpNode op = new("javaTokPlusCurly_dontKeep"); if (n.add(op)) op.add(TokNode(javaTokPlusCurly_dontKeep(tn.text))); } if (n instanceof TokNode) { TokNode tn = cast n; if (containsSubList(tn.tok, ll("=", "", ">"))) { OpNode op = new("splitAtDoubleArrow"); if (n.add(op)) op.add(ObjectNode(splitAtDoubleArrow(tn.tok))); } L<Int> l = indicesOfSubList(tn.tok, ll("&", "", "&")); if (nempty(l)) { OpNode op = new("split at &&"); if (n.add(op)) for (L<S> subTok : splitAroundSubListIndices(tn.tok, l, 3)) op.add(TokNode(subTok)); } } if (n instanceof ObjectNode) { ObjectNode on = cast n; O o = on.obj; if (o instanceof S) n.add(TextNode((S) o)); Collection c; if (on.obj instanceof Collection && l((c = (Collection) on.obj)) == 2) { OpNode op = new("Split Collection"); if (n.add(op)) for (O e : c) op.add(ObjectNode(e)); } } }
Began life as a copy of #1017536
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: | #1017599 |
Snippet name: | Computation tree for parsing with OpNode results [dev.] |
Eternal ID of this version: | #1017599/1 |
Text MD5: | 26f71f3a7137f4b83eb28cc285e4aa1e |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-07-29 17:05:41 |
Source code size: | 1870 bytes / 73 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 380 / 561 |
Referenced in: | [show references] |