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

Allow nonexhaustive rules #233

Merged
merged 4 commits into from
Apr 9, 2021
Merged

Allow nonexhaustive rules #233

merged 4 commits into from
Apr 9, 2021

Conversation

dario23
Copy link

@dario23 dario23 commented Jun 21, 2020

I had a try at allowing nonexhaustive rules, as proposed in #179.

@kevinmehall
Copy link
Owner

Thanks!

I'm not sure "nonexhaustive" is the right term for this -- in the context of Rust, "a non-exhaustive" match is when not all cases are covered by patterns. In rust-peg, one might expect exhaustive / non-exhaustive to mean that the parser covers all possible inputs / will fail for some inputs.

Not sure of a better term, though. #[no_eof]?

This attribute should also probably only be allowed with pub as it has no effect when calling the rule from other rules.

@kevinmehall kevinmehall merged commit 12448fe into kevinmehall:master Apr 9, 2021
@kevinmehall
Copy link
Owner

Merged as #[no_eof] pub rule name() = ...

@dario23 dario23 deleted the allow-nonexhaustive-rules branch April 9, 2021 06:09
@jocutajar
Copy link

Excellent. Might be worthwhile adding how to detect the non-eof match. I suppose we can check end position and compare to input length. Haven't tried yet.

I also notice in the MR:

To opt in to non exhaustive parsing, add the nonexhaustive modifier before the rule keyword.

But here you say #[no_eof]. Which one then? :)

Thanks a lot!

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