-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Transition rustc Parser to proc_macro token model #63689
Comments
…henkov Move token gluing to token stream parsing work towards rust-lang#63689, this moves token gluing from the lexer to the token tree layer. This is only a minimal step, but I like the negative diff here. r? @petrochenkov
Move token gluing to token stream parsing work towards #63689, this moves token gluing from the lexer to the token tree layer. This is only a minimal step, but I like the negative diff here. r? @petrochenkov
made some initial stabs in matklad@0d46730. The idea is to remove cases from Faced a couple of problems:
EDIT: more stabs at https://github.com/matklad/rust/tree/decomposed-neq. fixed all parser problems, not it looks like we are loosing jointness info somewhere.. |
Fond next obstacle: in macros by example,
produces |
@petrochenkov is ^ a good plan? Or are there any bigger plans for refactoring quote, which we should do first? |
I never thought about this case. IIRC, the stuff in |
Hm, so that we represent For rustc, I feel like it's better to stick with the current model for the time being |
Note there's another place, besides macro_rules! m {
($()>>=*) => ()
}
m!(>>= >>=); |
This worked out quite nicely for rust-analyzer: rust-lang/rust-analyzer#1858. I think we should maybe do this for rustc as well, but probably after moving to disjoint model. |
After the recent refactorings, we can actually completely hide this type. It should help with rust-lang#63689.
Currently, there are two different approaches for dealing with composite tokens like
>>
in rustc.>
and>
, when necessary.At the moment, the first approach is used by the parser, and the second approach is used by the proc_macro API. It would be good to move the parser to the decomposed approach as well, as it is somewhat more natural, more future-compatible (one can introduce new tokens) and having two of a thing is bad in itself!
Here are some relevant bits of the code that handle composed model:
Here are the bits relevant to decomposed model:
Note that the
tt
matcher inmacro_rules
eats one composed token, and this is affects language specification.That is, when we transition to decomposed model, we'll need to fix this code to eat one composed token to maintain backwards compatibility.
The text was updated successfully, but these errors were encountered: