[Haskell-cafe] An irritating Parsec problem

Andrew Coppin andrewcoppin at btinternet.com
Wed Oct 15 15:22:51 EDT 2008

I like Parsec. I use it for everything. But it does have one irritating 

Consider the following parser:

  expressions = many1 expression

Suppose this is the top-level parser for my language. Now suppose the 
user supplies an expression with a syntax error half way through it. 
What I *want* to happen is for an error to be raised. What *actually* 
happens is that Parsec just ignores all input after that point. So if 
"+" is not a valid token, but the user writes

  x = 1; y = 2; z = 3 + z; w = 4;

then what my program receives back is "x = 1; y = 2; z = 3", as if 
everything parsed successfully. But actually it has ignored half the 
input! o_O

Does anybody know how to fix this irratiting quirk? I can see why it 
happens, but not how to fix it.

More information about the Haskell-Cafe mailing list