1. I am not writing a parser, one already exists and can be brought in about as easy as your code sample.
2. I am translating the AST to rdf which lets me work on the AST with production rules
3. If I wanted templates I would use templates.  What I do do is start out with an abstract representation and then apply say 20 simple transformations that step by step fill in the details to get to code.  Speed is OK because we have indexes,  rete networks and other tricks.
4. People are not doing it yet and this is why people are saying code reuse is hard, etc. 
5. The transformations are written in a sparql derived rule format that itself uses the transformation system to add features by composition.