我试着这样做:
解析表单中的文本:
一些文字#{0,0,0}一些文字#{0,0,0}#{0,0,0}更多文字#{0,0,0}
进入一些数据结构的列表:
[内部"一些文本",外部(0,0,0),内部"一些文本",外部(0,0,0),外部(0,0,0),内部"更多文本",外部(0, 0,0)]
所以这些#{a,b,c} -bits应该变成与文本其余部分不同的东西.
我有这个代码:
module ParsecTest where
import Text.ParserCombinators.Parsec
import Monad
type Reference = (Int, Int, Int)
data Transc = Inside String | Outside Reference
deriving (Show)
text :: Parser Transc
text = do
x <- manyTill anyChar ((lookAhead reference) <|> (eof >> return (Inside "")));
return (Inside x)
transc = reference <|> text
alot :: Parser [Transc]
alot = do
manyTill transc eof
reference :: Parser Transc
reference = try (do{ char '#';
char …Run Code Online (Sandbox Code Playgroud)