Refactoring the code generator to use the visitor pattern.