Context Free Grammar Generator Python