1 | sclass PTElement { |
2 | AI_BottomUpParser1.Word word; |
3 | double weight = 1, totalWeight; |
4 | L<PTElement> children; |
5 | PTElement parent; |
6 | |
7 | S plusWeight(S s) { |
8 | if (weight == 1 && totalWeight == 1) ret s; |
9 | S a = formatDouble(weight, 2), b = formatDouble(totalWeight, 2); |
10 | ret s + " [" + a + (eq(a, b) ? "" : ", total " + b) + "]"; |
11 | } |
12 | |
13 | S text() { ret word == null ? null : word.text(); } |
14 | S category() { null; } |
15 | } |
16 | |
17 | sclass ChooseCategory extends PTElement { |
18 | L<S> categories; |
19 | |
20 | *(AI_BottomUpParser1.Word *word, L<S> *categories) {} |
21 | |
22 | toString { ret plusWeight(word.text() + " (" + n2(categories, "category", "categories") + ")"); } |
23 | } |
24 | |
25 | sclass HaveCategory extends PTElement { |
26 | S category; |
27 | ai_Reconstructed reconstruction; // optional |
28 | |
29 | *(AI_BottomUpParser1.Word *word, S *category) {} |
30 | *(AI_BottomUpParser1.Word *word, S *category, ai_Reconstructed *reconstruction) {} |
31 | |
32 | toString { ret plusWeight(quote(word.text()) + " as " + category); } |
33 | S category() { ret category; } |
34 | } |
35 | |
36 | sclass ChoosePart extends PTElement { |
37 | ai_Reconstructed reconstruction; |
38 | |
39 | *(AI_BottomUpParser1.Word *word, ai_Reconstructed *reconstruction) {} |
40 | |
41 | toString { |
42 | S hint = reconstruction.production.simplificationHint; |
43 | ret plusWeight( |
44 | reconstruction.a.text() + " + " + reconstruction.b.text() |
45 | + " [" + reconstruction.production + "]"); |
46 | } |
47 | S category() { ret reconstruction.production.c; } |
48 | } |
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: | #1017394 |
Snippet name: | Parse Tree Classes [Include] |
Eternal ID of this version: | #1017394/24 |
Text MD5: | 4f1ce3a5ac75aa8f3c470499a2922b11 |
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-23 23:00:17 |
Source code size: | 1462 bytes / 48 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 515 / 1156 |
Version history: | 23 change(s) |
Referenced in: | [show references] |