-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relative tokenizer #14270
base: main
Are you sure you want to change the base?
Relative tokenizer #14270
Conversation
I have been thinking about this. Couldn't this be implemented by doing a later pass on the tokens or the AST that computes the difference and relative positions? Or perhaps we include more information on the metadata so it can be done by a later pass? |
I'm not fully convinced this is the right step on the road to incremental parsing. My intention was to explore a direction and see where we can go from there. Metadata in the current form is the problem. What I would like to see is separation of AST and position/range metadata so were possible to keep AST nodes in one place and have metadata stored elsewhere. A weak map would be nice but I'm not aware of one for OTP. |
@lukaszsamson something like this for the tracking? https://github.com/jonatanklosko/elixir_ast_ranges I honestly don't think a weak map would be that hard to implement in C as you could send messages when a reference/resource is GCed, so I think we could explore solutions alongside that. |
This is an attempt at making the tokenizer produce relative tokens. My intention is to enable building an incremental parsers better suited to LSP use case. With relative tokenization and parsing it may be possible to build a parser that does not need to rebuild the entire AST on each document edit.
Design choices:
#{
The current state:
:elixir_tokenizer.to_absolute_tokens
are identical to the ones produced by absolute mode. I verified this over elixir source as well as a number of other projects.Examples: