Got most of a port of centi-typescript to Rust going! #20
simonbuchan
started this conversation in
Show and tell
Replies: 1 comment
-
Improved error output and fixed comparing signature argument lengths, but inference is not working at all... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The repo: https://github.com/simonbuchan/tts ("Tiny TypeScript")
Thought this would be a good way to really prove I understand what's going on, especially as Rust is very angry at you for trying a lot of the patterns in this repo!
Pretty dang bare, doesn't have a lot of stuff yet, especially notably:
Def(#2)
) - but I have a planEnded up flattening the syntax and symbol table trees into flat lists so I could use indices (the typical Rust solution to messy structures), so it's often horribly verbose right now. The syntax table is especially interesting as it's so heterogenous - I ended up using a macro to generate wrapper types, resulting in some pretty messy internals. There's a lot to improve there, in particular generating a proper visitor - I ended up having to hand-write a tree dumper!
Similarly, this drops the syntax parent pointers and only keeps symbol table parent pointers - good enough for the current uses.
The binder and checkers had a bit of back-and-forwards about handling lifetime checking - I don't think it's quite perfect, but it's good enough for now. (It was pretty gnarly at points!)
I suspect that a lot of the recursive descent that the binder and checker does could be completely flattened with a flat syntax / symbol list - they both end up being post-order traversals of the logical tree, so it seems like there should be a good way to take advantage and just do some sort of direct mapping.
Beta Was this translation helpful? Give feedback.
All reactions