Incremental parsing and left folds

Adam Langley agl at imperialviolet.org
Sat Feb 2 16:34:24 EST 2008


On Feb 1, 2008 5:06 PM, Adam Langley <agl at imperialviolet.org> wrote:
> I think one could get around this by having a couple of states, the
> latter being a list of all the additional ByteStrings that the parser
> has received. Then, after having prospectively failed a certain parse
> path, the failure must include the list of additional data, which can
> be merged into the new state for the next prospective path. This
> failure value must be internal and, at the top level, translated into
> a more user-friendly failure.

That was actually bit tougher than I thought, but I got something working:
  http://www.imperialviolet.org/Incremental.hs

Half the bottom functions are still commented out because I got bored,
but the plus operator works (I think). I managed a couple of simple
tests that I threw at it.

I'm pretty sure the cutContinuation is a terrible hack but, apart from
having continuations in both directions, it was the best that I could
come up with. However, I obvious don't understand Parsec because I
made the try operator redundant, and I'm pretty sure that shouldn't
have happened.


AGL

-- 
Adam Langley                                      agl at imperialviolet.org
http://www.imperialviolet.org                       650-283-9641


More information about the Libraries mailing list