Nadrieril / dhall-rust

Maintainable configuration files, for Rust users
Other
303 stars 27 forks source link

Conversions to Pest of 0-repetition ABNF rules fail #227

Closed eggyal closed 2 years ago

eggyal commented 2 years ago

Some ABNF rules, such as the path-empty rule defined in RFC3896§3.3, resolve to the empty string via repetitions of exactly 0 occurrences:

path-empty    = 0<pchar>

Alas, repetitions of exactly 0 occurrences are (currently) invalid in pest.

Perhaps abnf_to_pest could check for such a condition, then output an empty property value as described in "A thoughtful introduction to the pest parser" under Writing the grammar:

Section names and property keys must not be empty, but property values may be empty (as in the line ip= above).

Edit: Realised that the above refers to the sample INI format being parsed in that example, not the grammar of Pest itself. I guess support for 0-repetitions will be required in Pest?

Nadrieril commented 2 years ago

Yeah, we could make that work. I'm sure there's a way to ask pest to match the empty string