Download Jar. Libraryless. Click here for Pure Java version (11139L/82K).
!7 p-exp { PTElement input = ai_parseToCulledTree("What is {this funny thing}"); PTElement pat = ai_parseToCulledTree("What is X"); matchTrees(input, pat); } svoid matchTrees(PTElement pat, PTElement input) { print("Matching: " + pat + " / " + input); if (pat == null || input == null) ret; if (pat instanceof ChooseCategory && input instanceof ChooseCategory) { HaveCategory l = cast first(pat.children); HaveCategory r = cast first(input.children); if (l != null && r != null && eq(l.category, r.category)) { print("Using category: " + l.category); matchTrees(l, r); } ret; } if (pat instanceof HaveCategory && input instanceof HaveCategory) { matchTrees(first(pat.children), first(input.children)); ret; } if (pat instanceof ChoosePart && input instanceof ChoosePart) { for i to 2: matchTrees(pat.children.get(i), input.children.get(i)); ret; } print("Non-matching classes: " + className(pat) + " vs " + className(input)); }
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: | #1017737 |
| Snippet name: | Parse Tree Matching Spike [dev.] |
| Eternal ID of this version: | #1017737/9 |
| Text MD5: | 987316029676575b4d84ff5a69c8e0c4 |
| Transpilation MD5: | 120ffd9eba6e394a9b00e9661bbc7381 |
| 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-08-05 20:01:58 |
| Source code size: | 1041 bytes / 32 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 810 / 1759 |
| Version history: | 8 change(s) |
| Referenced in: | [show references] |