1 | abstract sclass CTNode { |
2 | new LinkedHashSet<CTNode> children; |
3 | |
4 | toString { ret shortClassName(this) + ": " + toString2(); } |
5 | abstract S toString2(); |
6 | |
7 | bool add(CTNode n) { ret children.add(n); } |
8 | } |
9 | |
10 | sclass TextNode > CTNode { |
11 | S text; |
12 | |
13 | *() {} |
14 | *(S *text) {} |
15 | |
16 | S toString2() { ret quote(text); } |
17 | } |
18 | |
19 | sclass TokNode > CTNode { |
20 | L<S> tok; |
21 | |
22 | *() {} |
23 | *(LS *tok) {} |
24 | |
25 | S toString2() { ret sfu(tok); } |
26 | |
27 | public bool equals(O o) { ret stdEq(this, o, 'tok); } |
28 | public int hashCode() { ret stdHash(this, 'tok); } |
29 | } |
30 | |
31 | sclass ObjectNode > CTNode { |
32 | O obj; |
33 | |
34 | *() {} |
35 | *(O *obj) {} |
36 | |
37 | S toString2() { ret sfu(obj); } |
38 | |
39 | public bool equals(O o) { ret stdEq(this, o, 'obj); } |
40 | public int hashCode() { ret stdHash(this, 'obj); } |
41 | } |
42 | |
43 | sclass OpNode > CTNode { |
44 | S op; |
45 | bool haveResult; |
46 | O result; // this is the result coming back up from the operation |
47 | |
48 | *() {} |
49 | *(S *op) {} |
50 | |
51 | S toString2() { ret haveResult ? result + " <- " + op : op; } |
52 | |
53 | public bool equals(O o) { ret stdEq(this, o, 'op); } |
54 | public int hashCode() { ret stdHash(this, 'op); } |
55 | |
56 | void setResult(O o) { |
57 | result = o; |
58 | haveResult = true; |
59 | } |
60 | } |
Began life as a copy of #1017532
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1017535 |
Snippet name: | Computation Tree Include v1 |
Eternal ID of this version: | #1017535/4 |
Text MD5: | 80674d47beb9d0cb6973e417e10e6007 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-07-29 17:00:14 |
Source code size: | 1202 bytes / 60 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 429 / 964 |
Version history: | 3 change(s) |
Referenced in: | [show references] |