|Ned Batchelder : Blog | Code | Text | Site|
Code generation with Cog
» Home : Blog : February 2004
Cog is a code generation tool I wrote to solve some problems at work. It's based on embedding Python in source files to generate code (we use it to generate C++, for example).
I'm really happy with the way Cog turned out. Some would say that Cog isn't a code generation tool at all, but just a file munger that can be used for code generation. They would be right, Cog does much less than most "code generators". But it was written to munge files in just the way you need to when generating code. Cog only does one thing, and it does it well: it executes chunks of Python it finds in text files, capturing the output and writing it into the file alongside the original code.
Download it, try it out, and let me know what you think.
For more about code generation in general, try: