I've created a weekend hack that allows you to specify a minimal grammar and then generates text (which can be code) using it.
It's called Choice Words (https://github.com/fdb/choicewords) It can generate poems but also generative designs (see the README).