Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix minor min-parsing issues #87

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 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,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
Expand All @@ -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)
}
4 changes: 2 additions & 2 deletions src/verus.pest
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down