Skip to content

Commit

Permalink
Min-parse strings/chars/... with parens/... inside
Browse files Browse the repository at this point in the history
Otherwise, the following code would parse just fine on `--verus-only`
formatting, but would fail when attempting to do the rustfmt part:

```
let x = '(' == '(';
```
  • Loading branch information
jaybosamiya-ms committed Aug 20, 2024
1 parent eb3a463 commit 5e101e3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/verus-minimal.pest
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ raw_byte_string = @{
"b" ~ raw_string
}

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

multiline_comment = @{
"/*" ~ (multiline_comment | (!"*/" ~ ANY))* ~ "*/"
}
Expand All @@ -59,7 +63,7 @@ file = {

/// Region of code that doesn't contain any Verus macro use whatsoever
non_verus = @{
(!("verus" ~ WHITESPACE* ~ "!" ~ WHITESPACE* ~ "{") ~ (string | raw_string | byte_string | raw_byte_string | ANY))*
(!("verus" ~ WHITESPACE* ~ "!" ~ WHITESPACE* ~ "{") ~ (string | raw_string | byte_string | raw_byte_string | char | ANY))*
}

/// An actual use of the `verus! { ... }` macro
Expand Down Expand Up @@ -90,5 +94,5 @@ paren_tree = {

/// _Technically_ not a Rust token, but we're trying to do a minimal parser _anyways_
token = {
!("{" | "}" | "[" | "]" | "(" | ")") ~ ANY
!("{" | "}" | "[" | "]" | "(" | ")") ~ (string | raw_string | byte_string | raw_byte_string | char | ANY)
}

0 comments on commit 5e101e3

Please sign in to comment.