[Haskell-cafe] Tokenizing and Parsec

Magnus Therning magnus at therning.org
Tue Jan 12 04:47:34 EST 2010


2010/1/12 Günther Schmidt <gue.schmidt at web.de>:
> Hi all,
>
> I've used Parsec to "tokenize" data from a text file. It was actually quite
> easy, everything is correctly identified.
>
> So now I have a list/stream of self defined "Tokens" and now I'm stuck.
> Because now I need to write my own parsec-token-parsers to parse this token
> stream in a context-sensitive way.
>
> Uhm, how do I that then?
>
> Günther
>
> a Token is something like:
>
> data Token = ZE String
>           | OPS
>           | OPSShort String
>           | OPSLong String
>           | Other String
>           | ZECd String
>             deriving Show

Maybe this can be of help (though it's for Parsec 2):
http://therning.org/magnus/archives/367

It's not the only example of this either, tagsoup-parsec is available
on Hackage.

/M

-- 
Magnus Therning                        (OpenPGP: 0xAB4DFBA4)
magnus@therning.org          Jabber: magnus@therning.org
http://therning.org/magnus         identi.ca|twitter: magthe


More information about the Haskell-Cafe mailing list