I'm using a FParsec to write a small org-mode parser, for fun, and I'm having a little trouble with parsing a table row into a list of strings. My current code looks like this:
let parseRowEntries :Parser<RowEntries, unit> =
let skipInitialPipe = skipChar '|'
let notaPipe = function
| '|' -> false
| _ -> true
let pipeSep = pchar '|'
skipInitialPipe >>. sepEndBy (many1Satisfy notaPipe) pipeSep
|>> RowEntries
This works fine until you parse the string |blah\n|blah\n|blah| which should fail because of the newline character. Unfortunately simply making \n false in the notaPipe condition causes the parser to stop after the first 'blah' and say it was parsed successfully. What I want the manySatisfy to do is parse (almost) any characters, stopping at the pipe, failing to parse for newlines (and likely the eof character).
I've tried using charsTillString but that also just halts parsing at the first pipe, without an error.
|foo|\n|bar|\nis valid, but|foo\n|bar\nis invalid because there's no terminating pipe? In that case I think what you want is something using thebetweencombinator. I'll do a few tests and then write up an answer with what I've found. - rmunn