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
Support for raw string literals #39
Comments
Thanks for the report. Are you interested in making a PR to add this? Here's a similar example from a Rust bundle: |
Yes, I’m interested in making a PR. I see that |
All scope names are just by convention, but the basic ones are defined here: https://macromates.com/manual/en/language_grammars So you could use |
You might also want to refer to #31 |
Thanks, those resources should help. |
Looking at this now – @infininight @sorbits is there a way to use begin capture groups inside |
There is not, no. So currently we cannot support the raw string escaping mechanism. I do have an open issue about supporting |
OK, thanks. Maybe what I'll do is create a full set of rules including escapes for n=1, i.e. |
That’s a great idea. I was about to suggest you could also do a rule for |
It seems like raw string literals with more than one |
Implemented in #40 |
As discussed in #39, adds support for raw strings (Swift 5, SE-0200), supporting all escapes in a single #"...\#n..."# string, and limited support for raw strings with more #s due to grammar limitations.
Support for raw string literals
SE-0200, implemented in Swift 5, added support for raw string literals, which are string literals that add
#
characters to their delimiters, and that partially ignore escape sequences like\n
and\\
. The above-linked Swift Evolution proposal goes into greater detail about their design, but a quick overview follows.Overview of raw string literals
Traditional string literals interpret character sequences beginning with
\
as escape sequences, but raw string literals interpret these as literal characters:You can use any number of
#
characters as the delimiters of a raw string literal:If you want to use an escape sequence in a raw string literal, the escape sequence includes the same number of
#
characters as the delimiters:Note, the reason you can use any number of
#
characters is to allow literal\#
sequences in a raw string literal without escaping:Swift also allows combining raw string literals with multiline string literals:
The issue: swift.tmbundle doesn’t support raw string literals
As seen in some of the examples above, swift.tmbundle highlights raw string literals as if they were traditional string literals. That means that some valid sequences involving
\
characters are marked as invalid, and some invalid sequences involving\
characters are only partially marked as invalid:The text was updated successfully, but these errors were encountered: