FParsecを使用してs式言語からのlispスタイルのコメントを解析しようとしています。この前のスレッドで1行のコメントを解析するのに少し助けがありました-FParsecパーサーを変換して空白を解析する方法
それは解決されましたが、複数行のコメントを解析する必要があります。これが現在のコードです-
/// Read whitespace character as a string.
let spaceAsStr = anyOf whitespaceChars |>> fun chr -> string chr
/// Read a line comment.
let lineComment = pchar lineCommentChar >>. restOfLine true
/// Read a multiline comment.
/// TODO: make multiline comments nest.
let multilineComment =
between
(pstring openMultilineCommentStr)
(pstring closeMultilineCommentStr)
(charsTillString closeMultilineCommentStr true System.Int32.MaxValue)
/// Read whitespace text.
let whitespace =
lineComment <|>
multilineComment <|>
spaceAsStr
/// Skip any white space characters.
let skipWhitespace = skipMany whitespace
/// Skip at least one white space character.
let skipWhitespace1 = skipMany1 whitespace
残念ながら、multilineComment解析は成功しません。これはコンビネータであるため、ブレークポイントを設定したり、機能しない理由を分析したりすることはできません。
それが機能しない理由はありますか?