Converting an AST back into code

Hi,
I'm working on a pet project of mine, and in it I'm getting an AST
which I then wish to write out as code (not in the original language
that produced the AST, but one that's close, even though that doesn't
matter much).
The AST I'm getting is very, very detailed, and a fair number of
tokens seem to depend on context for interpretation.
I can certainly see how I can brute-force my way out of this, and I'm
pretty sure it'll involve some of that. But what I was wondering about
is whether there are tricks and good ideas to doing this right/more
easily, and evil traps to be wary of.
Cheers,
--
Robin Berjon - http://berjon.com/
Feel like hiring me? Go to http://robineko.com/