In fact, it looks like a 'grammar' is quite similar to most programmings languages, http://www.contextfreeart.org/mediawiki/index.php/CFDG_HOWTO. It makes the iteration and stopping-bounds easy to create. It also allows uses functions to define shapes, so you can use them again easily.