How to Lex, Parse, and Serialize-to-XML email messages

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to Lex, Parse, and Serialize-to-XML email messages

Costello, Roger L.
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 at doe.org>

I have successfully transformed it into this XML:

        <From>
            <Mailbox>
                <DisplayName>John Doe</DisplayName>
                <Address>john at 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-to-xml-email-messages-using-alex-and-happy

/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/


Reply | Threaded
Open this post in threaded view
|

How to Lex, Parse, and Serialize-to-XML email messages

Mats Rauhala
That was an excellent question / parser. Thank you

--
Mats Rauhala
MasseR
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130628/8730416c/attachment.pgp>