Incremental parsing and left folds
Adam Langley
agl at imperialviolet.org
Mon Feb 4 00:40:30 EST 2008
On Feb 2, 2008 1:34 PM, Adam Langley <agl at imperialviolet.org> wrote:
> 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.
Well, I still think that it's a pretty big hack, but since I'd worked
out how to do choice in an incremental parser I added it to
binary-strict in darcs.
http://darcs.imperialviolet.org/darcsweb.cgi?r=binary-strict;a=summary
specifically:
http://darcs.imperialviolet.org/darcsweb.cgi?r=binary-strict;a=headblob;f=/src/Data/Binary/Strict/IncrementalGet.hs
And since I had the choice operator, I added some other parsing stuff
(many, <|> etc) to IncrementalGet and Get, than abstracted it out with
a class
http://darcs.imperialviolet.org/darcsweb.cgi?r=binary-strict;a=headblob;f=/src/Data/Binary/Strict/Class.hs
Now you can write parsers which work in both strict and incremental
modes. If you remove the monomorphism restriction, they can do both in
the same module. As a test I'm writing an HTTP parser (one which
handles all the RFC stuff that no one ever believes is valid - like
newlines in lists) and it seems to be working pretty well.
AGL
--
Adam Langley agl at imperialviolet.org
http://www.imperialviolet.org 650-283-9641
More information about the Libraries
mailing list