String and CharStream<'a> in FParsec
문제
I would like to parse a big sentence, which can contain names in fsharp. I posit that names is in the form first name + last name. In the absence of a first name list (can't find, will do later), I say that a first name is a string of length 4 or more, same for the last name.
When I try my very smart parser
let firstorlastname x = (parray 4 letter) x
firstorlastname "JEAN"
firstorlastname "CHRISTOPHE"
So, it works for both, but the problem is that it consumes only 4 characters, which is not the desired behaviour for Christophe. I would like the whole word to be consumed.
How can I instruct FParsec to consume the entire word, but fail if the word is less than 4 characters ?
해결책
Haven't tested it, but I think this should do it:
let firstOrLastName = manyMinMaxSatisfy 4 Int32.MaxValue isLetter
제휴하지 않습니다 StackOverflow