[Haskell-cafe] Re: Parsec question
Benedikt Huber
benjovi at gmx.net
Tue Dec 23 07:25:49 EST 2008
Erik de Castro Lopo schrieb:
> Erik de Castro Lopo wrote:
>
>> qualifiedIdentifier :: CharParser st [ String ]
>
> Ahh, figured it out myself:
>
> qualifiedIdentifier :: CharParser st [ String ]
> qualifiedIdentifier = do
> i <- identifier
> r <- dotIdentifier
> return (i : r)
> where
> dotIdentifier = do
> char '.'
> i <- identifier
> r <- dotIdentifier
> return (i : r)
> <|> return []
>
> Does that look sane to people who know Haskell and Parsec
> better than me?
Hi Erik,
have a look at the module Text.ParserCombinators.Parsec.Combinator.
Those functions should help you to build up parsers from smaller
building blocks.
Using sepBy1, the above parser can be written as
dot = T.dot lexer
qualifiedIdentifier = sepBy1 identifier dot
benedikt
More information about the Haskell-Cafe
mailing list