I'm trying to parse a large file looking for instructions on each line and for 
a section end marker but Parsec's manyTill function causes stack overflow, as 
you can see in the following example (I'm using ghci 6.8.3):

> parse (many anyChar) "" ['a'|x<-[1..1024*64]]

It almost immediately starts printing "aaaaaaaaaaa...." and runs to completion.

> parse (manyTill anyChar eof) "" ['a'|x<-[1..1024*1024]]
*** Exception: stack overflow

I guess this happens because manyTill recursively accumulates output from the 
first parser and returns only when it hits the 'end' parser. Is it possible to 
write a version of 'manyTill' that works like 'many' returning output from 
'anyChar' as soon as it advances through the list of tokens?

Thanks,
Daniel


      
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to