다른 문자열에서 간단한 문자열을 구문 분석하려면 어떻게해야합니까? 내가 표현에서, 집합하지만 더 문자열 사이의 부동 소수점을 구문 분석하지 않으FParsec을 사용하여 문자열 값을 구문 분석하는 방법
let str s = pstring s
let floatBetweenBrackets = str "[" >>. pfloat .>> str "]"
다음 FParsec 튜토리얼에서
주어진 다음 코드가있다.Sth. 마찬가지로 :
Location := LocationKeyWord path EOL
는 도우미 함수
let test p s =
match run p s with
| Success(result,_,_) -> printfn "%A" result
| Failure(message,_,_) -> eprintfn "%A" message
그리고 파서 기능을 감안할 때 : let pLocation = ...
내가 전화
test pLocation "Location /root/somepath"
그것은 인쇄해야에게 "/root/somepath"
내 첫 번째 시도는 다음과 같이 튜토리얼 코드를 수정했습니다 :
let pLocation = str "Location " >>. str
을하지만이 나에게 오류를 제공합니다
Error 244 Typeerror. Expected:
Parser<'a,'b>
Given:
string -> Parser<string,'c>
The type CharStream<'a> doesn't match with the Type string
완벽한 해답 - 감사합니다! –