-
-
Notifications
You must be signed in to change notification settings - Fork 314
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
Parse tokens, not strings #147
Conversation
Add a `Synom` trait along with impls for all the base types here, to be used later.
Ah and it's worth noting that of course parsing strings is still supported. The |
Thanks for rebasing this @alexcrichton (And also introducing the Synom trait / rewriting most of it :S which simplifies things a lot).
I have an idea of how to improve this, and fix the None-delimited Sequence and operator associativity problem with Expressions, but I think I'm going to wait until this gets merged to work on it. Unfortunately, even once |
9463b2b
to
16bb9b0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not going to review this thoroughly right now but based on a spot check, this is exactly what I had in mind. Merge when ready!
Any idea what the future looks like for combining adjacent spans? Ideally the +=
token would have a single span. As I understand it, our parsing guarantees that +
and =
are adjacent bytes in the input, so we could even make do with an implementation that panics when merging spans that are not adjacent.
There is a circular dependency here between proc-macro2 and synom. I will make a PR to drop the dependency of proc-macro2 on synom. |
Aw shucks, I was hoping we'd have an infinite bootstrap chain where if you compile proc-macro 0.N it requires syn 0.M which requires proc-macro 0.N-1 which requires syn 0.M-1 which requires... |
Oh I haven't thought about this much, but I think it'd be quite plausible! If |
I hope you're not serious. dtolnay/proc-macro2#4 |
How much of https://github.com/dtolnay/syn/issues/created_by/Arnavion is fixed by this? |
Also, I'm converting one of my proc macro crates to master to try it out. Shall I file bugs for useful / necessary features that were removed (no more |
The second is a known issue. We'll probably solve it either in proc-macro2 (if it looks like proc-macro proper is going go gain that functionality), or I'll make a separate LiteralExt crate to add the methods I want which doesn't have to be built unless you need the feature dtolnay/proc-macro2#9 |
(we should probably have an issue for both of them on syn though - go ahead and file :)) |
This commit builds off @mystor's work to finish porting the parser to working over tokens, not strings as it was previously. The tokens here come directly from the
proc_macro2
crate which is the intended-to-be-stabilized interface ofproc_macro
itself.In the end this should mean that conversion from a
TokenStream
to asyn
AST and back should be a lossless transformation in terms of contextual information like spans. This'll lead to far better error messages from the compiler and such.This comes with quite heavy changes to the
synom
crate, including deletion of a number of macros that were no longer uses and aren't as useful in this "lossless" world. Comments are of course always welcome!Closes #137
Closes #142