-
Notifications
You must be signed in to change notification settings - Fork 180
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
Added rust-style raw string syntax support for the Rhai Tokenizer #908
Conversation
Looks great, except that whether Hopefully JS formatters can successfully format most of Rhai... Do you know how other languages handle the same? |
Python uses r"raw string" syntax to use string with no escapes in it, but I think Rust is pretty unique in allowing the programmer to specify, in place, the number of "#"'s they need to represent the data without any distracting escape characters. I see what you're saying about JavaScript though. I think raw strings could supplement the verbatim ones while adding negligible overhead, and aligning the language more with standard Rust features. |
I do agree that the I agree that this can be very useful -- I have immediate uses for this myself in my projects! Would you mind taking care of the review questions as well? |
Could you clarify what/where the review questions are? |
Your review says "Pending", probably why I can't see it. Is there a "submit review" button? |
Ah OK! Pressed it! |
I'll need to fix it up a bit because you cannot just return |
@cellomath Come to think of it, since |
My objective was to match Rust's syntax as much as possible, and prefixing raw strings with an "r" is pretty common in other languages too. Changing the syntax would undermine this, but if you like, I wouldn't be opposed for your |
Rhai already deviates from Rust quite significantly, such as using One more benefit is that the code is cleaner because we no longer have any raw strings without hashes... EDIT: Caught a position bug |
I have an implementation out and it seems to make the code quite a bit simpler. So we'd have:
|
Okay, I see your point. Maybe keeping the languages separated makes it more distinguishable anyways! |
Now we just have to figure out a way to make syntax highlighting work... Not sure how the Rust grammar does it... Do you know anything about this? |
Not sure what you mean. Can you link to Rhai's existing syntax highlighting? I'm not too familiar with language servers, but I figured they used something similar to regular expressions. If the syntax highlighter uses the Rhai parser, it should automatically appear as a string literal, since that's what the parser yields from the raw string literal syntax |
Added support for Rust-style raw-string literal syntax in Rhai.
Example: