
Hi, May be it's a frequently asked question, but I have been unable to find my way in the parsec-3.0.0 library when trying to write a small parser with Parsec that could work with ByteStrings. I mean, there is the Text.Parsec.ByteString module which allows to parse a file using ByteStrings, but the parser one needs to write must parse ByteStrings instead of Strings (that is, something like having a "Parsec Bytestring ()" type, unless I'm completely misunderstanding the situation). My problem is that I do not manage to write primitive parsing combinators (like string, satisfy, letter, etc.) to define my language's tokens. I'm surely missing some primitive somewhere (may be the Text.Parsec.Prim.token, though I do not really manage to use it). Thanks in advance, F.

On Fri, Jun 19, 2009 at 1:51 PM, Fernand
but the parser one needs to write must parse ByteStrings instead of Strings (that is, something like having a "Parsec Bytestring ()" type, unless I'm completely misunderstanding the situation). My problem is that I do not manage to write primitive parsing combinators (like string, satisfy, letter, etc.) to define my language's tokens.
Why would you want to do that ? After all, those combinators are already available in Text.Parsec.Char : they work on any Stream instance whose token type is Char, which happens to be the case for ByteString. -- Jedaï

Chaddaï Fouché пишет:
On Fri, Jun 19, 2009 at 1:51 PM, Fernand
wrote: but the parser one needs to write must parse ByteStrings instead of Strings (that is, something like having a "Parsec Bytestring ()" type, unless I'm completely misunderstanding the situation). My problem is that I do not manage to write primitive parsing combinators (like string, satisfy, letter, etc.) to define my language's tokens.
Why would you want to do that ? After all, those combinators are already available in Text.Parsec.Char : they work on any Stream instance whose token type is Char, which happens to be the case for ByteString.
Oh. You're right, I wonder how that escaped me. Thank you ! F.
participants (2)
-
Chaddaï Fouché
-
Fernand