Converting an AST back into code

Robin Berjon robin at berjon.com
Mon Feb 23 11:40:20 GMT 2009


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/







More information about the london.pm mailing list