Skip to content

Commit

Permalink
Fix rust syntax file to recognize byte strings and c strings. (#3452)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jmcorey and James Corey authored Sep 5, 2024
1 parent d8f7928 commit 2308bc5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions runtime/syntax/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,29 @@ rules:
- type: "\\b(bool|str|isize|usize|((i|u)(8|16|32|64))|f32|f64)\\b"

- constant.string:
start: "\""
start: "[bc]?\""
end: "\""
skip: '\\.'
rules:
- constant.specialChar: '\\.'

- constant.string:
start: "r#\""
start: "[bc]?r#\""
end: "\"#"
rules: []

- constant.string:
start: "r##\""
start: "[bc]?r##\""
end: "\"##"
rules: []

- constant.string:
start: "r###\""
start: "[bc]?r###\""
end: "\"###"
rules: []

- constant.string:
start: "r####+\""
start: "[bc]?r####+\""
end: "\"####+"
rules: []

Expand Down

0 comments on commit 2308bc5

Please sign in to comment.