Solutions to the Context Free Grammar exercise