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

Formal arg with ellipsis #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dingxiangfei2009
Copy link
Contributor

This PR will

  • add support for ellipsis marker in formal argument lists
  • (TODO) test on formal argument parsing

@dingxiangfei2009
Copy link
Contributor Author

Oh, shoot. I was planning to open this as a draft PR.

Nevertheless, I would like to gather early feedback since I think it will be great to know the best practices from you. 😄

Copy link
Owner

@ebkalderon ebkalderon left a comment

Choose a reason for hiding this comment

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

Thanks for the pull request! Your code seems correct, but it doesn't appear to work for me, unfortunately, likely due to a subtle issue with separated_list_partial() unintentionally hard bailing due to it consuming the trailing , and failing to parse the subsequent ellipsis.

You should be able to reproduce the failure by running the following command:

echo '{ foo, ... }: foo' | cargo run -p nix-parser --example viewer

Comment on lines +45 to +47
map(preceded(tokens::comma, tokens::ellipsis), |ellipsis| {
Some(ellipsis)
}),
Copy link
Owner

Choose a reason for hiding this comment

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

I think the closure could just as easily be replaced with:

map(preceded(tokens::comma, tokens::ellipsis), Some),

@ebkalderon
Copy link
Owner

By the way, commit c807b89 has updated util::error_expr_if() to no longer require a &str argument anymore. The method can now deduce the found token description using recognize(). I'm very sorry for the inconvenience. It should be easy to fix the conflicts, though; just need to remove the string arguments wherever they occur. Please let me know if you need any assistance!

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.

None yet

2 participants