Browsed by
Category: Code Generators

code generators and wizards

Code Generators

Code Generators

I like code generators for prototyping.

Probably the best way is to use python’s jinja2 as templating language and something like yaml for config…

Anyway, the code generator works by assembling a shell script with commands to be executed and heredocs that get redirected to their respective output files.

Now let’s look at codegen.t which is the template for the code generated. Notice the replacement of the dollar sign to prevent the shell from substitutions. You might need to introduce more replacements if things go wrong…

And now let’s look at some invocations of these macros…

And if you wonder, here is the corresponding config.yaml

Download: codegen.tgz