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

Support dividing statement lists into clauses/stanzas #79

Merged
merged 3 commits into from
Jul 8, 2024

Conversation

jaybosamiya-ms
Copy link
Collaborator

@jaybosamiya-ms jaybosamiya-ms commented Jul 5, 2024

This PR adds support for dividing statement lists into clauses/stanzas. This prevents the need for the empty // workaround to divide code into stanzas.

Specifically, with this PR, the following code is (now) considered well-formatted:

verus! {

fn fff() {
    reveal(f1);

    foo;

    bar;
    baz;
}

} // verus!

Prior to this PR, verusfmt would have collapsed the additional newlines around foo;. With this PR, we maintain the additional newlines (however if there are too many newlines, we bring it down to just the two, as a stylistic choice).

Note: this only adds support for stanzas for statement lists. It explicitly does not work in general contexts (such as dividing a single expression up via extra newlines). I believe that supporting stanzas at the statement level should cover most people's use cases for them, while limiting the scope of the shenanigans necessary for the parser to be able to handle the special case of the double/multi-newline.

Resolves #43

@jaybosamiya-ms jaybosamiya-ms requested a review from parno July 5, 2024 22:16
src/verus.pest Outdated Show resolved Hide resolved
src/verus.pest Show resolved Hide resolved
src/verus.pest Show resolved Hide resolved
@jaybosamiya-ms jaybosamiya-ms requested a review from parno July 8, 2024 18:26
@jaybosamiya-ms jaybosamiya-ms merged commit c5fdb28 into main Jul 8, 2024
8 checks passed
@jaybosamiya-ms jaybosamiya-ms deleted the double-newline branch July 8, 2024 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Preservation of stanzas
2 participants