It is often convenient to express grammar productions in BNF like
A ::= "car"
| "bike"
| ε
where ε represents an empty production rule; i.e., the nonterminal "A" could expand to the terminals "car", "bike", or nothing. However, unless I refactor my grammar, it is unclear to me how I would represent such a grammar in FParsec. I am aware of the 'choice' combinator, <|>
, but as far as I know there is no 'empty' combinator. I.e., a combinator that returns true and consumes no input.
I've searched the FParsec documentation high and low, but I have not found anything that does this, which surprises me, because this seems like a common scenario. I'm fairly new to FParsec (and combinators in general), so maybe I am just not using the right words. Any hints?