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 use of an empty array as default value in allowedStartRules option #493

Closed
XenoS-ITA opened this issue Feb 25, 2024 · 1 comment · Fixed by #526
Closed

Allow use of an empty array as default value in allowedStartRules option #493

XenoS-ITA opened this issue Feb 25, 2024 · 1 comment · Fixed by #526
Labels
good first issue Good for newcomers

Comments

@XenoS-ITA
Copy link
Contributor

How the feature should work

When an empty or null array is passed peggy should take the default value, which is the first rule.
Right now if you define allowedStartRules there is no method to use the first rule.

Use case behind it

In the following code, if the file is a library, all rules should be added as start instead if it is not the first rule should be taken

const output = peggy.generate(fileContent, {
    format: "commonjs", 
    output: "source", 
    allowedStartRules: isLibrary ? ["*"] : []
})

Even some kind of ENUM might be fine

@hildjj hildjj added the good first issue Good for newcomers label Feb 25, 2024
@hildjj
Copy link
Contributor

hildjj commented Jun 19, 2024

I'm making it so that null, undefined, and [] all get the default start rule.

hildjj added a commit to hildjj/peggy that referenced this issue Jun 19, 2024
…tartRules, all of which mean the default (first) rule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants