I'm looking to make a tool which generates method stubs from some given input. I've seen the ast
package, but it seems to represent an already parsed AST, which has information about where in the source file everything is. Importantly, you need to provide source information
I'm looking at generating a source file programatically, so I have no idea where in the final file my AST nodes will end up.
I'm wondering:
- Is there a better AST tool which lets you generate code without giving source file position information?
- If I give dummy information for positions in the
ast
package, will it pretty-print properly (i.e. ignore the position information)?
I realize I could do this all with text generation, but that seems type-unsafe and harder to deal with.