[Haskell-beginners] Parsec

C Gosch ch.gosch at googlemail.com
Fri Aug 6 15:02:48 EDT 2010


Ah wait ... I saw that I can get the input stream with
   getParserState,
as it is part of the state. If that is the currently remaining stream, I
could use any functions from ByteString
to skip over some parts or do whatever with them, and update the state to
the last position after the part I want
to skip.
Am I correct there, or am I then getting something in Parsec out of sync?
Guess I'll just try :)

Thanks!
Christian

2010/8/6 Patrick LeBoutillier <patrick.leboutillier at gmail.com>

> Hi,
>
> I started using Data.Binary yesterday for a project and it's nice. I'm
> not sure it's possible, but perhaps you could switch tools along the
> way:
>
> - Parse the ASCII bit with Parsec ;
> - Give the remaining ByteString to Data.Binary for the binary part ;
> - Switch back and forth as required.
>
> Patrick
>
>
> On Fri, Aug 6, 2010 at 5:03 AM, C Gosch <ch.gosch at googlemail.com> wrote:
> >
> >
> > 2010/8/6 Dean Herington <heringtonlacey at mindspring.com>
> >>
> >> At 11:42 PM +0200 8/5/10, C Gosch wrote:
> >>>
> >>> Hi,
> >>> does anyone here know their way around in Parsec?
> >>> I'm trying to parse a file which contains some binary parts too.
> >>> I have been using Parsec 3.0.1 to parse the first ASCII part, but all
> the
> >>> parsers are
> >>> returning Char type tokens, so it would not work with the binary parts
> ..
> >>> is there any way to do this?
> >>> I am using Text.Parsec.ByteString.Lazy.
> >>>
> >>> Note that I'm new to Haskell and Parsec, and doing this within a small
> >>> project that
> >>> I basically do to get a grip on Haskell (and Parsec, because it appears
> >>> to be really nifty and I want to learn more about it).
> >>>
> >>> Thanks for any hints,
> >>> Christian
> >>
> >> Parsing binary parts of a file is not inherently a problem.  A parser
> can
> >> return any type; different parsers in your application will likely
> return
> >> different types.
> >>
> >> If you include some code we'll be able to help you more specifically.
> >>
> >> Dean
> >
> > You're right, I probably used the wrong words .. I meant that apparently
> the
> > tokens Parsec uses are of type Char, and I would actually at some point
> > like to continue parsing, but using different tokens. Sorry if I still
> got
> > it wrong, I'm new :)  I can post some code later, as I don't have it here
> > right now.
> >
> > Cheers,
> > Christian
> >
> > _______________________________________________
> > Beginners mailing list
> > Beginners at haskell.org
> > http://www.haskell.org/mailman/listinfo/beginners
> >
> >
>
>
>
> --
> =====================
> Patrick LeBoutillier
> Rosemère, Québec, Canada
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100806/87d71200/attachment.html


More information about the Beginners mailing list