Problem with incomplete input when using Attoparsec

Posted by Dan Dyer on Stack Overflow See other posts from Stack Overflow or by Dan Dyer
Published on 2010-06-07T11:22:02Z Indexed on 2010/06/07 13:42 UTC
Read the original article Hit count: 222

Filed under:
|

I am converting some functioning Haskell code that uses Parsec to instead use Attoparsec in the hope of getting better performance. I have made the changes and everything compiles but my parser does not work correctly.

I am parsing a file that consists of various record types, one per line. Each of my individual functions for parsing a record or comment works correctly but when I try to write a function to compile a sequence of records the parser always returns a partial result because it is expecting more input.

These are the two main variations that I've tried. Both have the same problem.

items :: Parser [Item]
items = sepBy (comment <|> recordType1 <|> recordType2) endOfLine

For this second one I changed the record/comment parsers to consume the end-of-line characters.

items :: Parser [Item]
items = manyTill (comment <|> recordType1 <|> recordType2) endOfInput

Is there anything wrong with my approach? Is there some other way to achieve what I am attempting?

© Stack Overflow or respective owner

Related posts about haskell

Related posts about attoparsec