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

Export a parser for Types and refactor a bit parser #1227

Merged
merged 2 commits into from
Apr 4, 2023

Conversation

yannham
Copy link
Member

@yannham yannham commented Apr 4, 2023

This PR has been done as part of fixing #1187, and split as a stand-alone change. For some reason I needed to parse types. This PR exposes the rule for parsing type in the LALRPOP grammar.

I also noticed that the code already present had duplication, and that I was going to add one more copy of the parse_term_tolerant and parse_term methods. Those methods are now implemented once and for all for any parser generated by Lalrpop, and have been renamed to be more consistent with the rest of the codebase.

@yannham yannham requested a review from vkleen April 4, 2023 14:14
@github-actions github-actions bot temporarily deployed to pull request April 4, 2023 14:18 Inactive
Copy link
Member

Choose a reason for hiding this comment

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

This feels like it's coupling us quite tightly to larlpop implementation details. I'm not if that's a problem but it's worth pondering.

Copy link
Member

Choose a reason for hiding this comment

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

Well, maybe that feeling only comes from all the underscores 😅 It seems the only real internal we're coupling to here is grammar::__ToTriple.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wouldn't say it does, because LalrpopParser ist in fact mostly a facade for Lalrpop-generated parsers. But everything else in the Nickel codebase should use the ErrorTolerantParser trait, which is mostly independent from Lalrpop (that's not entirely true, because of error type and so forth, but I think it's hardly avoidable). Maybe I should make this trait private? I wonder if it's possible to depend on private trait for a public trait. Let me try.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think 1c31f53 decouples the trait implements a bit, in a cleaner way, although it's a tad more verbose (we had to repeat the interface of parse_tolerant and parse_strict).

Copy link
Member

Choose a reason for hiding this comment

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

I think a private trait makes sense here; even though the coupling objection was a bit vague in the first place. 👍

@github-actions github-actions bot temporarily deployed to pull request April 4, 2023 14:49 Inactive
@yannham yannham merged commit 629a2bf into master Apr 4, 2023
4 checks passed
@yannham yannham deleted the task/export-type-parser branch April 4, 2023 17:24
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