diff --git a/src/verus-minimal.pest b/src/verus-minimal.pest index 2a28443..1f77655 100644 --- a/src/verus-minimal.pest +++ b/src/verus-minimal.pest @@ -45,6 +45,10 @@ raw_byte_string = @{ "b" ~ raw_string } +char = @{ + "'" ~ ("\\'" | !"'" ~ ANY) ~ "'" +} + multiline_comment = @{ "/*" ~ (multiline_comment | (!"*/" ~ ANY))* ~ "*/" } @@ -59,12 +63,12 @@ file = { /// Region of code that doesn't contain any Verus macro use whatsoever non_verus = @{ - (!("verus!" ~ 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 verus_macro_use = ${ - "verus!" ~ WHITESPACE* ~ "{" ~ (WHITESPACE | COMMENT)* ~ verus_macro_body ~ (WHITESPACE | COMMENT)* ~ "}" ~ WHITESPACE* ~ ("//" ~ WHITESPACE* ~ "verus!" ~ WHITESPACE*)? + "verus" ~ WHITESPACE* ~ "!" ~ WHITESPACE* ~ "{" ~ (WHITESPACE | COMMENT)* ~ verus_macro_body ~ (WHITESPACE | COMMENT)* ~ "}" ~ WHITESPACE* ~ ("//" ~ WHITESPACE* ~ "verus" ~ WHITESPACE* ~ "!" ~ WHITESPACE*)? } /// Anything inside the `verus! { ... }` macro @@ -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) } diff --git a/src/verus.pest b/src/verus.pest index 04223d9..04e3284 100644 --- a/src/verus.pest +++ b/src/verus.pest @@ -82,12 +82,12 @@ file = { /// happens, then we need to make sure that we aren't accidentally starting /// parsing in the middle of the macro_rules macro body itself. Similarly, strings. non_verus = @{ - (!("verus!" ~ WHITESPACE* ~ "{") ~ (macro_rules | string | raw_string | byte_string | raw_byte_string | ANY))* + (!("verus" ~ WHITESPACE* ~ "!" ~ WHITESPACE* ~ "{") ~ (macro_rules | string | raw_string | byte_string | raw_byte_string | ANY))* } /// An actual use of the `verus! { ... }` macro verus_macro_use = ${ - "verus!" ~ WHITESPACE* ~ "{" ~ (WHITESPACE | COMMENT)* ~ verus_macro_body ~ (WHITESPACE | COMMENT)* ~ "}" ~ WHITESPACE* ~ ("//" ~ WHITESPACE* ~ "verus!")? + "verus" ~ WHITESPACE* ~ "!" ~ WHITESPACE* ~ "{" ~ (WHITESPACE | COMMENT)* ~ verus_macro_body ~ (WHITESPACE | COMMENT)* ~ "}" ~ WHITESPACE* ~ ("//" ~ WHITESPACE* ~ "verus" ~ WHITESPACE* ~ "!")? } /// Anything inside the `verus! { ... }` macro