I was finding implementing IMAP a bit painful using the simple command structure that we used for POP and SMTP. IMAP is more of a mini line langauge than anything else. So I was going to write a parser with ANTLR but I found one as part of another project and its BSD license (essentially). It is a project called epost. I'll be messing with the parser a bit and if it all works out well I'll just use their grammar/antlr. That may mean ditching some of the donated IMAP code (sorry) which attempted to start us off by using the same structure as our SMTP/POP code. The good news is that while I may be putting the cart before the horse I think this will shave weeks off of our effort.
The BSD project is epost for those interested.
humm unfortunately it looks like the parser is the only thing here worth lifting. A few utilities ...