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
Completely optional parser rules should be marked as errors #1400
Comments
My two cents:
|
So to clarify, this grammar would be valid, right?
Also, what about fragments? Should optionality be checked for them, too? |
It would be helpful if that works, but I'm not sure whether it's problematic for the parser.
No, a fragment should be allowed to consume no tokens. When calling a fragment rule, treat its content as if it was part of the calling rule. |
OK. I've changed the validation to reflect these cases, and to fix false-positive errors with alternative groups. |
Related to #1398
A parser rule that potentially consumes no input from the text is not valid, as the parser can potentially not attempt to create it:
This leads to unexpected behavior, and generally serves no purpose. We have a similar validation for terminals already, and should have one for parser rules as well.
The text was updated successfully, but these errors were encountered: