dashbitco / nimble_parsec

A simple and fast library for text-based parser combinators

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

utf8_string/2 and ascii_string/2 should support min: 0

tmbb opened this issue · comments

commented

Motivation: say I want to parse a line which might be empty.

Currently, I have to do this:

line = choice([utf8_string([not: ?\n], min: 1), string("")]) |> ignore(string("\n"))

I'd like to be able to write:

line = utf8_string([not: ?\n], min: 0) |> ignore(string("\n"))

I propose defining utf8(chars, min: 0) as equivalent to choice([utf8_string([not: ?\n], min: 1), string("")]). Although implemented in a more efficient way if possible.