【发布时间】:2017-01-16 04:32:57
【问题描述】:
当尝试解析 {asdc,456,ghji,abc} 时,我运行
run specialListParser "{asdc,456,ghji,abc}"
解析器失败
错误发生在输入流的末尾。
期望:任何不在“,”、“,”或“}”中的字符
我基于这个answer定义了我的解析器:
let str : Parser<_> = many1Chars (noneOf ",")
let comma = pstring ","
let listParser = sepBy str comma
let specialListParser = between (pstring "{") (pstring "}") listParser
我错过了什么?
【问题讨论】:
-
“不工作”并不是一个很好的问题描述。
-
请比“不工作”更具体。你得到什么错误信息?尝试从this section of the FParsec tutorial 实现
test函数并运行test specialListParser "{def,ghi,jkl}"。它输出什么? -
基本上,您还没有提供minimal, complete and verifiable example 来证明您的确切问题,在您告诉我们更多信息之前很难给您有用的答案。
-
现在我看到了您的错误信息,我能够自己重现问题并修复它。