Warning: session_start(): open(/var/lib/php/sessions/sess_14oe0bf2a0m05t7ir712ka0hr6, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
abstract sclass Node {
new LinkedHashSet children;
toString { ret shortClassName(this) + ": " + toString2(); }
abstract S toString2();
bool add(Node n) { ret children.add(n); }
}
sclass TextNode > Node {
S text;
*() {}
*(S *text) {}
S toString2() { ret quote(text); }
}
sclass TokNode > Node {
L tok;
*() {}
*(LS *tok) {}
S toString2() { ret sfu(tok); }
public bool equals(O o) { ret stdEq(this, o, 'tok); }
public int hashCode() { ret stdHash(this, 'tok); }
}
sclass ObjectNode > Node {
O obj;
*() {}
*(O *obj) {}
S toString2() { ret sfu(obj); }
public bool equals(O o) { ret stdEq(this, o, 'obj); }
public int hashCode() { ret stdHash(this, 'obj); }
}
sclass OpNode > Node {
S op;
*() {}
*(S *op) {}
S toString2() { ret op; }
public bool equals(O o) { ret stdEq(this, o, 'op); }
public int hashCode() { ret stdHash(this, 'op); }
}
p-exp {
S input = first(mL("Monolog examples"));
TextNode root = new(input);
processNode_recursive(root, 10);
showFrame(jDynamicTree(root, func(Node n) -> Collection { n.children }));
}
svoid processNode_recursive(Node n, int depthCounter) {
if (n == null || depthCounter <= 0) ret;
processNode(n);
for (Node child : n.children)
processNode_recursive(child, depthCounter-1);
}
svoid processNode(Node 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 l = indicesOfSubList(tn.tok, ll("&", "", "&"));
if (nempty(l)) {
OpNode op = new("split at &&");
if (n.add(op))
for (L 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));
}
}
}