[Haskell-cafe] Need help with learning Parsec

C K Kashyap ckkashyap at gmail.com
Sun Jul 22 17:21:25 CEST 2012


I've updated the parser here -
https://github.com/ckkashyap/LearningPrograms/blob/master/Haskell/Parsing/xml_3.hs

The whole thing is less than 100 lines and it can handle comments as well.

I have an outstanding question - What's the second parameter of the parse
function really for?

Regards,
Kashyap

On Thu, Jul 19, 2012 at 8:31 PM, C K Kashyap <ckkashyap at gmail.com> wrote:

> Thank you so much ... I've updated my monad version here -
>
>
> https://github.com/ckkashyap/LearningPrograms/blob/master/Haskell/Parsing/xml_1.hs<https://github.com/ckkashyap/LearningPrograms/blob/master/Haskell/Parsing/xml_2.hs>
>
>
> and the Applicative version here -
> https://github.com/ckkashyap/LearningPrograms/blob/master/Haskell/Parsing/xml_2.hs
>
>
> The applicative version however does not seem to work.
>
> Is there a good tutorial that I can look up for Parsec - I am checking out
> http://legacy.cs.uu.nl/daan/download/parsec/parsec.html but  I am looking
> for a tutorial where a complex parser would be built ground up.
>
> Next I'd like to take care of escaped angular brackets.
>
> Regards,
> Kashyap
>
>
> On Thu, Jul 19, 2012 at 7:40 PM, Christian Maeder <
> Christian.Maeder at dfki.de> wrote:
>
>> Am 19.07.2012 15:41, schrieb Simon Hengel:
>>
>>  On Thu, Jul 19, 2012 at 03:34:47PM +0200, Simon Hengel wrote:
>>>
>>>>      openTag :: Parser String
>>>>      openTag = char '<' *> many (noneOf ">") <* char '>'
>>>>
>>>
>> if you disallow empty tags and "/" within tags, then you can avoid the
>> notFollowedBy construct by:
>>
>>        openTag = try (char '<' *> many1 (noneOf "/>")) <* char '>'
>>
>> C.
>>
>>
>>
>>>>      endTag :: String -> Parser String
>>>>      endTag str = string "</" *> string str <* char '>'
>>>>
>>>
>>> Well yes, modified to what Christian Maeder just suggested.
>>>
>>> Cheers,
>>> Simon
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120722/85a24bfb/attachment.htm>


More information about the Haskell-Cafe mailing list