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. 😄

@ebkalderon ebkalderon force-pushed the master branch 2 times, most recently from 1b900c2 to dc7ba6f Compare October 11, 2019 06:14
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!

@ebkalderon ebkalderon force-pushed the master branch 3 times, most recently from 0cf33fd to e1711bd Compare October 20, 2019 01:52
@ebkalderon ebkalderon force-pushed the master branch 2 times, most recently from 1562aa6 to c3b2a03 Compare October 28, 2019 07:12
@ebkalderon ebkalderon force-pushed the master branch 11 times, most recently from 8175c19 to 3fc0c94 Compare March 15, 2020 19:48
@ebkalderon ebkalderon force-pushed the master branch 3 times, most recently from 38b9cae to d5019aa Compare March 25, 2020 10:46
@ebkalderon ebkalderon mentioned this pull request Mar 27, 2020
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.

2 participants