Similar to any higher order combinator framework, rparsec program is not real easy to debug. When error does happen, especially when the production rule is complex, tracing down the error may take considerable amount of time. Though I do not think debugging rparsec is any harder than debugging parser generators, this is an undebatable problem that we should face.

My experience in using rparsec (and jparsec too), is that test driven development really helps. It is unfortunately hard to debug a complex parser object, but it is much easier for a small vanilla one. If the whole parser program is built with test cases that tests every tiny piece of logic, detecting and debugging an error becomes a much easier task.

Start from writing unit test case for every production rule before implementing it. Run the test case, see the red bar, and then implement the production rule to turn it to green.

That said, when you do encounter errors, here're a few things to check up.

Utilities that may help in troubleshooting:

Created by benyu benyu
On Mon Oct 23 23:25:06 CDT 2006
Using TimTam