When trying to parse {asdc,456,ghji,abc}
and I run
run specialListParser "{asdc,456,ghji,abc}"
the parser fails with
The error occurred at the end of the input stream.
Expecting: any char not in ‘,’, ',' or '}'
I defined my parser based on this answer:
let str : Parser<_> = many1Chars (noneOf ",")
let comma = pstring ","
let listParser = sepBy str comma
let specialListParser = between (pstring "{") (pstring "}") listParser
What am I missing?
Looks like your str
parser is consuming the final }
, so that between
never gets to see it. Change your str
parser to be many1Chars (noneOf ",}")
and it should work.
Alternately, noneOf [','; '}']
would also work, and might be more explicit about your intentions.