How can you detect when an FParsec parser has stopped without parsing all the input?
For example, the following parser p
stops when it finds the unexpected character d
and does not continue to parse the remainder of the input.
let test p str =
match run p str with
| Success(result, _, _) -> printfn "Success: %A" result
| Failure(errorMsg, s, _) -> printfn "Failure: %s %A" errorMsg s
let str s = pstring s
let a = str "a" .>> spaces
let b = str "b" .>> spaces
let p = many (a <|> b)
test p "ab a d bba " // Success: ["a"; "b"; "a"]