sprache/Sprache — pull request #24 by iSynaptic (2013-07-20 01:19:44+00:00)
Title: Enable parsing with partial success and multiple observations (info, warnings, and errors)

Note: I don't want this to be merged into the mainline yet. I want the Sprache community to discuss this idea.

One limitation of Sprache that I find frustrating is: once it hits it's first error it just stops parsing. A simple error recovery strategy that could be applied is to go into a "panic mode" - essentially when the parser fails, start consuming input until some "synchronization" token is parsed (e.g. in C-style language it could be the semi-colon or closing-brace characters). In order to enable this, I believe there would need to be some (invasive?) changes to the Sprache API.

I've implemented a rough pass at the changes for everyone to take a look at and weigh in. I still think the API needs some cleanup and consolidation. Also, I think the internals of the various parsers and parser extensions methods would need to be refreshed to reflect better support of the new API. Finally, I think position information should be available on the observations - just haven't made the changes yet.

Take a look at the IResult interface changes, the new ResultObservation and Observe classes, and the ManyWithPanic parser extension method (there is a test to show this in action).

Thoughts?