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

Unmacro parser combinators #6648

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

JackoCoolio
Copy link
Contributor

This PR converts a bunch of the macro parser combinators in parser.rs back into regular functions. They were previously converted to macros so that the rust compiler didn't explode, but it's gotten better since then, and I don't run into any issues with compilation. As a bonus, compiling roc_parse is now about 1.5s faster on my machine.

See zulip discussion here.

@JackoCoolio
Copy link
Contributor Author

Oops, looks like I forgot to check doctests

ayazhafiz
ayazhafiz previously approved these changes Apr 21, 2024
Copy link
Sponsor Member

@ayazhafiz ayazhafiz left a comment

Choose a reason for hiding this comment

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

Great change. Thank you!

This implementation requires that the type of the value impls `Clone`,
which means the function version of `succeed` cannot be used to succeed
with values of non-`Clone` types.

If this becomes an issue, we could either bring back the macro version,
or create a new `succeed_with` function that takes a `Fn() -> T`
argument. `succeed_with` could then be used to succeed with values that
aren't `Clone` by creating the value on-demand each time the parser is
run.
Previously said that `indented_seq` was similar to `and`, but it's more
like `skip_first`. `and` returns a tuple of both parsers' outputs, but
`indented_seq` only returns the output of the second parser, just like
`skip_first`.
@ayazhafiz
Copy link
Sponsor Member

This has conflicts now. @JackoCoolio would you prefer to resolve them or would you like one of us to pick up the conflict resolution?

Copy link

github-actions bot commented Jun 8, 2024

Thank you for your contribution! Sometimes PRs end up staying open for a long time without activity, which can make the list of open PRs get long and time-consuming to review. To keep things manageable for reviewers, this bot automatically closes PRs that haven’t had activity in 60 days. This PR hasn’t had activity in 30 days, so it will be automatically closed if there is no more activity in the next 30 days. Keep in mind that PRs marked Closed are not deleted, so no matter what, the PR will still be right here in the repo. You can always access it and reopen it anytime you like!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants