I\'m writing a converter between some dialects of the same programming language. I\'ve found a grammar on the net - it\'s complex and handles all the cases. Now I\'m trying
Once you have an AST, you'll need to write a tree walker that emits your program as the transformed source. You might even have an intermediate tree walker doing tree transformations depending upon the complexity of your changes.
That said, going through an AST step, may not be the best approach.
You might want to take a look at "Language Design Patterns" by Terrence Parr (Pragmatic Programmers). Chapter 11 addresses your type of program.
He mentions a tool, ANTLRMorph, that might be better suited for your problem.