parse formal languages from Python in an easy way