Framework for exploring (graphical) interpretations of context free grammars (CFGs).
For an introduction into the theory behind CFGs and a few usage examples, see Generative Art with Context-Free Grammars.
- Grammar
- A collection of terminals, non-terminals and production rules. Terminals are implemented as anonymous functions, non-terminals as strings.
- State
- An object that is passed to each of the (
lambda
) terminals. A graphics turtle “state” is included. - Backend
- Implements conversion form a state to some output
format. A backend for generating
.svg
images is included.
git clone https://github.com/l3kn/generative_cfg
cd generative_cfg
python setup.py install
Then the library can be imported using import generative_cfg
.
An easy way to get started is to modify and extend one of the example
files in examples/
.