Skip to content

Commit

Permalink
Add support for backslashed character literals
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybosamiya-ms committed Mar 3, 2025
1 parent 2fe6cd9 commit f146726
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

* Add support for backslashed character literals (e.g., `\t`, `\\`, `\u{00e9}`, etc.)

# v0.5.3

* Add support for `!is`/`!has` syntax (see [verus#1435](https://github.com/verus-lang/verus/pull/1435))
Expand Down
7 changes: 6 additions & 1 deletion src/verus.pest
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,12 @@ raw_byte_string = @{
}

char = @{
"'" ~ ("\\'" | !"'" ~ ANY) ~ "'"
"'" ~ (
("\\u{" ~ ASCII_HEX_DIGIT+ ~ "}")
| ("\\" ~ ANY)
| (!"'" ~ ANY)
) ~
"'"
}

byte = @{
Expand Down
4 changes: 4 additions & 0 deletions tests/rustfmt-matching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ fn test() {
let a = 12E+99_f64;
let x: f64 = 2.;
let x = (1,);
let t = 'x';
let t = '\\';
let t = '\t';
let t = '\u{00e9}';
}
"#;
compare(file);
Expand Down

0 comments on commit f146726

Please sign in to comment.