Had a little think about design. Would like to be flexible enough to support various output pipelines: should be able to write out a Sieve script or xml.
Implementing SieveParserVisitor seems like the best place to start. This visitor is designed to perform it's own tree recursion which suits well.
The classic first stage of the pipeline is to turn the tree recursion into a linear series of start and end events. For flexibility, these should be node based. This will end up a rather large API with each start and end calls for each concrete node type.
This would probably be enough to plugin custom output to strings including basic XML rendering. More stages in the pipeline would be required for more sophisticated such as XML pipelining.
On balance should be very do-able.