[Haskell-beginners] How to Lex, Parse, and Serialize-to-XML email messages

Costello, Roger L. costello at mitre.org
Fri Jun 28 11:30:30 CEST 2013


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/



More information about the Beginners mailing list