> Everything now is written with regexps, which can be good for
> skipping over cruft and targeting expected strings, but they
> fall apart fairly easily. It would be nice to have a more
> stable parsing framework that can handle these oddities (though
> I know they're all built on regexps, eventually). It would be
> nice to have something that could be used for IMAP servers,
> etc.
PEG might be what you want, there is implementation for Emacs -