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

feat(combinator): add separated #362

Merged
merged 3 commits into from
Nov 3, 2023
Merged

feat(combinator): add separated #362

merged 3 commits into from
Nov 3, 2023

Conversation

vwkd
Copy link
Contributor

@vwkd vwkd commented Nov 1, 2023

This attempts to add a separated parser that accepts a range similar to repeat.

Towards #98.

I tried to copy as much logic as possible from existing code. I'm unfamiliar with the code and may have missed some things, e.g. checkpoint resets, infinite loop checks, or correct error types. Please double check carefully and feel free to edit if it can be improved.

@vwkd vwkd changed the title feat: add separate feat: add separated Nov 1, 2023
@coveralls
Copy link

coveralls commented Nov 1, 2023

Pull Request Test Coverage Report for Build 6750273694

  • 71 of 138 (51.45%) changed or added relevant lines in 1 file are covered.
  • 4 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.3%) to 44.391%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/combinator/multi.rs 71 138 51.45%
Files with Coverage Reduction New Missed Lines %
src/ascii/mod.rs 1 52.55%
src/combinator/multi.rs 3 61.08%
Totals Coverage Status
Change from base Build 6722478717: -0.3%
Covered Lines: 1211
Relevant Lines: 2728

💛 - Coveralls

@vwkd vwkd changed the title feat: add separated feat(combinator): add separated Nov 1, 2023
@epage
Copy link
Collaborator

epage commented Nov 1, 2023

Thanks for moving this forward!

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clippy found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.

@vwkd
Copy link
Contributor Author

vwkd commented Nov 1, 2023

Hope this is now better and easier to review. Just to stress again, I'm not sure how correct this code is. Please review carefully.

Currently, the infinite loop checks for the element parser (not the separator parser) in separated0_ make one test fail.

@epage
Copy link
Collaborator

epage commented Nov 1, 2023

Hope this is now better and easier to review. Just to stress again, I'm not sure how correct this code is. Please review carefully.

Currently, the infinite loop checks for the element parser (not the separator parser) in separated0_ make one test fail.

This PR should not be changing behavior and duplicating the separated0 and separated1 bodies, its hard to tell what behavior changed for us to talk about it.

@vwkd
Copy link
Contributor Author

vwkd commented Nov 1, 2023

I must have misunderstood the request to keep separated0 and deprecating it.

As requested, I've changed it back such that seperated0 becomes separated0_ (and similar for 1). I've added tests, and moved the variable renames into a separate commit, such that the diff is more readable1. I've again removed the extra infinite loop checks for the element parsers (not the existing one for the separator parsers) - which was not in the existing implementation - such that all tests pass.

Please note, as requested I kept the implementation and the updating call sites in separate commits, but since the signature of the functions change, they can't be used at the existing call sites, which means there's no way to deprecate them without duplicating them. So currently, the implementation commit (feat(combinator): add separated) won't compile. The alternative would be to squash them together like they were before.

Slightly off topic: Maybe it would make sense to adopt a squash/rebase flow instead of a merge flow, such that individual commits of the PR can be purely for ease of readability and review, since they don't need to compile as the whole PR gets squashed into a single commit on the main branch. A linear history and readable commit log is a nice bonus.

Footnotes

  1. If GitHub's diff doesn't line up the functions correctly, it might be worth trying VSCode (. keyboard shortcut to open the PR in github.dev).

@epage
Copy link
Collaborator

epage commented Nov 2, 2023

I must have misunderstood the request to keep separated0 and deprecating it.

As requested, I've changed it back such that seperated0 becomes separated0_ (and similar for 1). I've added tests, and moved the variable renames into a separate commit, such that the diff is more readable1. I've again removed the extra infinite loop checks for the element parsers (not the existing one for the separator parsers) - which was not in the existing implementation - such that all tests pass.

This change should not be a breaking change. You can both split out separated0_ for reuse and keep separator0. See #241.

Slightly off topic: Maybe it would make sense to adopt a squash/rebase flow instead of a merge flow, such that individual commits of the PR can be purely for ease of readability and review, since they don't need to compile as the whole PR gets

Squash/rebase workflows lose valuable history and intentionally sending someone broken commits to review can be confusing.

@vwkd
Copy link
Contributor Author

vwkd commented Nov 3, 2023

I think I understand the request now. I've kept deprecated separated0 that reuse separated0_ internally (similar for 1) and a separated commit to remove them. This should keep each commit buildable.

@epage
Copy link
Collaborator

epage commented Nov 3, 2023

Everything should be good to go after these last couple of comments are resolved! Thanks for your work on this!

@vwkd
Copy link
Contributor Author

vwkd commented Nov 3, 2023

Addressed the remaining comments.

To lessen the breaking change before, I had considered delaying this to a follow up proposal. But since this is now a non-breaking additive change, now would be an opportunity to choose the right name while avoiding a breaking change in the future. I think naming it separate (verb, instead of adjective separated) would fit better and also align with the existing repeat.

@epage
Copy link
Collaborator

epage commented Nov 3, 2023

If you'd like to discuss name changes, I'd recommend looking into whats been done before on #95 and posting your idea there.

@epage epage merged commit bea2415 into winnow-rs:main Nov 3, 2023
@epage
Copy link
Collaborator

epage commented Nov 3, 2023

Thanks!

@vwkd vwkd deleted the separate branch November 3, 2023 21:46
@epage epage mentioned this pull request Dec 4, 2023
2 tasks
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.

3 participants