我有一个分析分析器,我主要以实用风格写作。在一种情况下(我使用 sepBy
的唯一时间),我对我的 eleol
解析器有问题。 首先,有几个定义:
eol = try (string "
")
<|> try (string "
")
<|> string "
"
<|> string "
"
<?> "eol"
betaLine = string "BETA " *> (StrandPair <$> p_int <*> p_int <*> p_int <*> (p_int *> p_direction) <*> p_exposure) <* eol
注: beataLine
工作完美(对于简洁性,我漏掉了 >p_int
的定义,以及:
*HmmPlus> parse betaLine "beta" "BETA 6 11 5 24 -1 oiiio
"
Right (StrandPair {firstStart = 6, secondStart = 11, pairLength = 5, parallel = Antiparallel, exposure = [Exposed,Buried,Buried,Buried,Exposed]})
问题在于此其它解析器, hmmMatchEmissions
:
hmmMatchEmissions = spaces *> (V.fromList <$> sepBy p_logProb spaces) <* eol <?> "matchEmissions"
*HmmPlus> parse hmmMatchEmissions "me" " 2.61196 4.43481 2.86148 2.75135 3.26990 2.87580 3.69681
"
Left "me" (line 2, column 1):
unexpected end of input
Now, if I remove the <* eol
from the parser definition, and remove the
from the line, it does work:
*HmmPlus> parse hmmMatchEmissions "me" " 2.61196 4.43481 2.86148 2.75135 3.26990 2.87580 3.69681"
Right (fromList [NonZero 2.61196,NonZero 4.43481,NonZero 2.86148,NonZero 2.75135,NonZero 3.2699,NonZero 2.8758,NonZero 3.69681])
那么,为什么 eol
在 beetaLine
中起作用,但不能在 hmmmm MatchEmissions
中发挥作用?
我要指出,这是我唯一使用 sepBy
的地方;这是否是一个线索?
最新消息:我做了以下工作,但现在却以不同的方式失败:/
reqSpaces = many1 (oneOf " ")
optSpaces = many (oneOf " ")
hmmMatchEmissions = optSpaces *> (V.fromList <$> sepBy1 p_logProb reqSpaces) <* eol <?> "matchEmissions"
失败者如下:
*HmmPlus> parse hmmMatchEmissions "me" " 0.123 0.124
"
Left "me" (line 1, column 10):
unexpected "0"
expecting eol
我将注意到,第10栏中未预料到的 0
是 0.124
符号的第一个字符。