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

Improved empty empty alternatives detection. #196

Closed
bd82 opened this issue May 22, 2016 · 0 comments
Closed

Improved empty empty alternatives detection. #196

bd82 opened this issue May 22, 2016 · 0 comments
Labels
Milestone

Comments

@bd82
Copy link
Member

bd82 commented May 22, 2016

The implementation of validateEmptyOrAlternative
https://github.com/SAP/chevrotain/blob/master/src/parse/grammar/checks.ts#L272

Does not take into account that an alternative may be empty indirectly.
For example:

$.OR([
     {ALT: () => { $.SUBRULE($.emptyRule)}}, /// emptyRule has no implementation. 
     {ALT: () => { $.CONSUME(Identifier)}}
     ]);

Another use case to take into account is:
What is an alternative is only sometimes empty?

$.OR([
     {ALT: () => { $.OPTION(() => { $.CONSUME(Integer)})}, 
     {ALT: () => { $.CONSUME(Identifier)}}
     ]);
@bd82 bd82 added the Bug 🪲 label May 22, 2016
@bd82 bd82 added this to the V1.0.0 milestone Sep 2, 2017
@bd82 bd82 closed this as completed in 8cf81ca Nov 16, 2017
@bd82 bd82 changed the title Empty alternatives detection will miss "indirectly" empty alternatives Improved empty empty alternatives detection. Dec 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant