How to Lex, Parse, and Serialize-to-XML email messages
Hi Folks, I am working toward being able to input any email message and output an equivalent XML encoding. I am starting small, with one of the email headers -- the "From Header" Here is an example of a From Header: From: John Doe <john@doe.org> I have successfully transformed it into this XML: <From> <Mailbox> <DisplayName>John Doe</DisplayName> <Address>john@doe.org</Address> </Mailbox> </From> I used the lexical analyzer "Alex" [1] to break apart (tokenize) the From Header. I used the parser "Happy" [2] to process the tokens and generate a parse tree. Then I used a serializer to walk the parse tree and output XML. I posted to stackoverflow a complete description of how to lex, parse, and serialize-to-XML email From Headers: http://stackoverflow.com/questions/17354442/how-to-lex-parse-and-serialize-t... /Roger [1] The Alex User's Guide may be found at this URL: http://www.haskell.org/alex/doc/html/ [2] The Happy User's Guide may be found at this URL: http://www.haskell.org/happy/
That was an excellent question / parser. Thank you -- Mats Rauhala MasseR
participants (2)
-
Costello, Roger L. -
Mats Rauhala