-
Notifications
You must be signed in to change notification settings - Fork 329
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
Compile-time url parsing 'url!' macro #136
Comments
Sounds feasible with a plugin, maybe not specific to URLs. Anything that implements |
I wonder whether regex would be enough to parse URLs? The language of URLs seem regular enough to me (I may be wrong though). |
@KiChjang A regex may(?) be able to separate the components of an URL, but the parser as specified in https://url.spec.whatwg.org/#url-parsing does more stuff along the way such as percent-decoding, IDNA, resolving relative URLs, normalizing (anti)slashes, collapsing Making a plugin generic over Another approach might be to skip string parsing entirely. All fields of |
Larger explanation of the above, copied from IRC:
|
@SimonSapin @KiChjang just to prevent duplicate efforts, are either of you working on this currently? |
No I'm not working on it at all. You can assign the issue to yourself. |
Opened a PR #137 |
Implement 'url!(..)' macro servo/rust-url#136 servo/rust-url#137 <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8622) <!-- Reviewable:end -->
Implement 'url!(..)' macro servo/rust-url#136 servo/rust-url#137 <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8622) <!-- Reviewable:end -->
Implement 'url!(..)' macro servo/rust-url#136 servo/rust-url#137 <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8622) <!-- Reviewable:end -->
…ugin); r=SimonSapin servo/rust-url#136 servo/rust-url#137 Source-Repo: https://github.com/servo/servo Source-Revision: ea690a2dff64d1cb4eb668473d62f1bbcb19f7c8
…ugin); r=SimonSapin servo/rust-url#136 servo/rust-url#137 Source-Repo: https://github.com/servo/servo Source-Revision: ea690a2dff64d1cb4eb668473d62f1bbcb19f7c8 UltraBlame original commit: 5bb91f3403d68562020f7bb5215820646e7cc5c6
…ugin); r=SimonSapin servo/rust-url#136 servo/rust-url#137 Source-Repo: https://github.com/servo/servo Source-Revision: ea690a2dff64d1cb4eb668473d62f1bbcb19f7c8 UltraBlame original commit: 5bb91f3403d68562020f7bb5215820646e7cc5c6
…ugin); r=SimonSapin servo/rust-url#136 servo/rust-url#137 Source-Repo: https://github.com/servo/servo Source-Revision: ea690a2dff64d1cb4eb668473d62f1bbcb19f7c8 UltraBlame original commit: 5bb91f3403d68562020f7bb5215820646e7cc5c6
There's a |
Inspired by sfackler/rust-postgres-macros which is a compile time SQL parser
There are ton of instances in servo, where we do something like
Url::parse("http://mozilla.com").unwrap()
. It'd be great if we could do that validation at compile time with a macro (e.g.url!("http://mozilla.com")
).I have no idea how feasible this is, just throwing around the idea.
The text was updated successfully, but these errors were encountered: