peggy icon indicating copy to clipboard operation
peggy copied to clipboard

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

Open XenoS-ITA opened this issue 1 year ago • 0 comments

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

XenoS-ITA avatar Feb 25 '24 18:02 XenoS-ITA