Fix rust syntax file to recognize byte strings and c strings. (#3452)

In rust, there are some prefixes that may be part of the string literal.
String literals of the form b"test" (and br##"test"## etc) are byte
strings (as opposed to unicode strings), and similarly, string literals
of the form c"test" are C zero-terminated strings.  Hence, added optional
prefixes to each of the string regular expressions so the prefix will be
recognized as part of the string.

Built and tested after fix.

Co-authored-by: James Corey <jc-git@neniam.net>
This commit is contained in:
James M Corey 2024-09-05 09:41:17 -07:00 committed by GitHub
parent d8f7928b74
commit 2308bc5555
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -22,29 +22,29 @@ rules:
- type: "\\b(bool|str|isize|usize|((i|u)(8|16|32|64))|f32|f64)\\b" - type: "\\b(bool|str|isize|usize|((i|u)(8|16|32|64))|f32|f64)\\b"
- constant.string: - constant.string:
start: "\"" start: "[bc]?\""
end: "\"" end: "\""
skip: '\\.' skip: '\\.'
rules: rules:
- constant.specialChar: '\\.' - constant.specialChar: '\\.'
- constant.string: - constant.string:
start: "r#\"" start: "[bc]?r#\""
end: "\"#" end: "\"#"
rules: [] rules: []
- constant.string: - constant.string:
start: "r##\"" start: "[bc]?r##\""
end: "\"##" end: "\"##"
rules: [] rules: []
- constant.string: - constant.string:
start: "r###\"" start: "[bc]?r###\""
end: "\"###" end: "\"###"
rules: [] rules: []
- constant.string: - constant.string:
start: "r####+\"" start: "[bc]?r####+\""
end: "\"####+" end: "\"####+"
rules: [] rules: []