I have the following subexpression for parsing quotes, which have the following format
"5.75 @ 5.95"
So I have this parsec expression for parsing it
let pquote x = (sepBy (pfloat) ((spaces .>> (pchar '/' <|> pchar '@' )>>. spaces))) x
It works great. Unless there is a finite space in my input as the delimiter expression begins to consume content. So I wrapped it around an attempt that works and seems, from what I understand, more or less what it should have been.
let pquote x = (sepBy (pfloat) (attempt (spaces .>> (pchar '/' <|> pchar '@' )>>. spaces))) x
As I don't know fparsec so well, I wonder if there is a better way to write this. it seems a bit heavy (although still very manageable, of course)
source
share